somebodil26 downloadsBuild the notes you choose into a read-only website that looks like your vault and opens from a file.
An Obsidian plugin that builds the notes you choose into a website to read them: one zip archive, with an index.html in it that you open with a browser. The site looks like your vault, because Obsidian itself draws every note for it, and it cannot be edited.
index.html: no server, no network. The same files also work on a web server or on GitHub Pages as they are.The plugin is not in the list of community plugins of Obsidian yet. Until it is, put it into a vault by hand:
main.js, manifest.json and styles.css..obsidian/plugins/vault-to-site/ in your vault. .obsidian is a hidden folder: a file manager shows it only when it is told to show hidden files. On a phone, a file manager or the app you sync with can do this.The files of a release are built by GitHub from the commit of its tag, and carry a signed statement of that: gh attestation verify main.js --repo somebodil/vault-to-site checks it.
vault-to-site.zip in your vault. Unpack it and open index.html with a browser. On a phone, Share or open hands the archive to another app. The archive holds a README.txt for the one who gets it: how to open the site, and how to put it on the web. For the web, see also Putting the site on GitHub Pages.Under Written as you choose what a build writes, and where, from the root of the vault:
vault-to-site.zip): one file. The archive of the build before gives way only when the new one is whole: a build that is stopped or fails leaves it as it was. A file with that name that is not an archive of this plugin is not written over: the build is refused, and you choose another name or remove the file. An archive is known by what it holds, as a folder is, so the one of the build before is read once to look. The same holds for a file that comes to that name while the site is built..vault-to-site): the same files, unpacked. The site is written elsewhere and moved to its place at the end, so here too the site of the build before stays as it was when a build is stopped or fails. Moving in, a build takes away the site of the build before and nothing else in the folder, so a folder that is also a copy of a repository keeps its .git. A folder with files in it is written to only when it holds a vault-to-site.json that this plugin wrote. Any other folder with files in it is refused. So is a build when a file of yours lies where an extra file is to go: remove it, or give the extra file another path. A path with a part that is . or .. is refused, for the folder and for the archive. Obsidian does not show a folder whose name starts with a dot, so the pictures of the site do not turn up among those of your vault.While a site is built, it lies in .vault-to-site-cache, a folder at the top of the vault that Obsidian does not show, in a folder of its own with a name that is drawn by chance for each build. Every build empties .vault-to-site-cache before it starts and takes it away when it ends, so what a build that broke off left there is gone with the next one. Keep nothing of yours in it, and choose another place for a site. A site that is whole is moved from there to its place. Where it cannot be moved, as onto another disk that a link in the vault leads to, it is copied, which takes longer. Two builds in one vault at the same time, as one in Obsidian and one by a program, do not go together: the one that starts later empties the folder under the other, which fails and leaves its site of before as it was.
What lies where a build writes is never part of a site. A build goes by the place in the settings and by what it finds there. An archive or a folder that you rename or move away is put aside: the next build writes a new one where the setting says. What you put aside is a file like any other from then on, and goes into a site only when a note uses it: mind that an archive of before holds the notes that were in the site then. When you rename a folder above the place, the setting follows.
If you sync the vault, keep it out of the sync: with git, add vault-to-site.zip, .vault-to-site/ and .vault-to-site-cache/ to .gitignore.
A program has nobody to look at a dialog: obsidian-cmd-runner starts Obsidian without its window, on a build server after a push or from a script, and runs the command Build a site there. No dialog opens then, and the site is built at once. Install the runner with npm install -g obsidian-cmd-runner (Node.js 22.18 or later, on Linux or macOS).
obsidian-cmd-runner --vault notes --plugin somebodil/vault-to-site --command vault-to-site:build
Told nothing more, it goes by what the plugin has saved in the vault, in .obsidian/plugins/vault-to-site/data.json. Without that file, as in a fresh copy of a repository that does not hold it, it goes by the settings the plugin begins with, which still leave out type: private and publish: false. Where nothing is ticked, the whole vault goes in, and where no place is named, the site is an archive vault-to-site.zip in the vault. It is better to say in the run what goes in, by a property that every note of the site must have. Then a new note does not go in only because it is there:
{
"ticks": { "on": [""] },
"only": "publish: true",
"format": "folder",
"folder": "_site"
}
The command is given these as settings. With the file as site.json in the vault:
obsidian-cmd-runner --vault notes --plugin somebodil/vault-to-site \
--command vault-to-site:build --arg "settings=$(cat notes/site.json)"
The file holds the settings of the dialog under the names ticks, exclude, properties, include, only, extra, format (zip or folder), zip and folder.
ticks has the lists on and off: paths from the root of the vault, where "" is the whole vault, and Private/ and /Private mean Private. A path that is no folder and no file of the vault makes the run fail and is named. A path that is in both lists is left out.ticks gives both lists: what you left out in the dialog is not kept.settings, as when the word is written wrong, does not fail: it names them in one line and goes by what is saved.width is given beside the settings (--arg width=900): how wide a note is taken to be, in pixels, for what is drawn to fit it, as a diagram is. To begin with it is 1100, the width of a window on a computer. A width that is not a number from 320 to 10000 makes the run fail.--json.index at the top of the site, as a web server opens index.html. Without one, the first note at the top of the list, in the order of its names./ or Ctrl+K. A line that is found opens its note at that line.On a narrow window, as on a phone, the two sides lie under the note, and the note moves aside for them: by their buttons, or with a finger. A finger that moves the note to the right uncovers the files, one that moves it to the left the outline, and the other way covers them again. The note follows the finger, and where it is let go decides: past the middle, or flicked, and the side stays open. A wide table or a block of code is still moved sideways inside itself. In Safari on an iPhone, a finger that starts at the very edge of the screen is Safari's: it goes back a page.
The site is made for these browsers, and tried in them:
The style sheets copied from Obsidian set these versions: their colors are written with light-dark(), which Chrome has from version 123, and they blur with backdrop-filter, which Safari reads without a prefix from version 18. Other browsers, as Firefox, may show the site as well, but it is not made for them.
A PDF on a phone or a tablet is a link that opens it in the viewer of the browser, which shows all of it. Their browsers draw a PDF inside a page badly: Safari on an iPhone draws only its first page, cut to the size of its frame. On a computer the PDF is also shown in the page, under the link.
These decide, in this order. A rule always wins over a tick, and a rule that leaves out wins over one that takes in.
The ticks. A ticked folder takes in everything inside it, also what you add later. Take the tick off a folder or a note inside it to leave that out. What is left out stays left out when you rename or move it in Obsidian. A rename that Obsidian does not see, as one that a sync brings, is not followed, and the note is ticked again under its new name. The dialog names the old path, so that you can take the tick off again.
Leave out by path. JavaScript regular expressions, separated by commas. A path that one of them matches stays out. Upper and lower case are the same.
| Input | What stays out |
|---|---|
^Archive/ |
Everything in the top-level folder Archive |
(^|/)_templates/ |
Every folder called _templates, however deep |
^Archive/, \.pdf$ |
The folder Archive, and every PDF |
A comma is part of a pattern when it is escaped (\,), inside square brackets, inside a group, or inside a quantifier ({1,3}). A pattern that is not a valid regular expression stops the build until you correct it or take it out: a rule that does not work keeps nothing out. *.png is such a pattern; write \.png$.
Leave out by property. One property a line, as key: value. A note that has one of them stays out. To begin with these are type: private and publish: false. A key alone, as draft:, is every note that has that property, whatever it holds.
A value between slashes is a regular expression, as in the rule for paths: the note stays out when the expression finds something in what the property holds. Upper and lower case are the same. Of a property that is a list, each item is tried by itself. Letters after the last slash are flags: i, m, s and u are taken (i changes nothing), and any other letters there make the line one that does not work.
| Input | What stays out |
|---|---|
type: /^(private|meta)$/ |
A note whose type is private or meta |
tags: /^draft/ |
A note with a tag that starts with draft |
status: /wip/ |
A note whose status has wip somewhere in it |
A value is read as an expression when it starts with a slash and ends with a second slash, or with a second slash and letters after it. So a/b/c and // are plain text, but /usr/bin is read as an expression with the flags bin, which does not work: write it as one, /^\/usr\/bin$/.
A pattern that is not a regular expression, or a line that is not a property, keeps nothing out. The dialog says which one it is, and no site is built until it is corrected or taken out.
Take in only by path. Regular expressions, separated by commas, written as under Leave out by path. When there is one, a ticked note goes in only when one of them matches its path; a rule that keeps a note out still wins. Empty to begin with: then every ticked note goes in. With the whole vault ticked, ^Guide/, ^Notes/20\d\d- takes of it the folder Guide and the notes of Notes that start with a year.
Only notes are asked for a pattern. A picture or another file goes in with the note that uses it, wherever it lies.
Take in only by property. One property a line, as publish: true, with a value between slashes for a regular expression as above. When there is one, a ticked note goes in only with such a property; a rule that keeps a note out still wins. Empty to begin with: then every ticked note goes in. This is the rule for a site that a program builds: see Building by a program.
Put a file at a path of its own. One file a line, as Resume.pdf: Papers/Resume.pdf: the file of the vault after the colon goes into the site under the path before it, here at its top, where its address stays the same from build to build. Such a file is named one by one, by its whole path, and goes in whatever the ticks and the other rules say, also from a folder that a pattern keeps out. A note cannot be named: a note goes in only as a note. Nor can a canvas or a base, a path where the site itself writes, as index.html, or two paths of which one lies inside the other, as a and a/b.pdf. The step Look over lists these files, and a line that names no file of the vault stops the build.
In the site, such a file is in the list of files on the left, under the path before the colon, and opens there as a file that a note uses does: a PDF in the middle of the page, under a link that opens it alone. The path in the vault does not show. A note of the site that links to or embeds the same file leads to that path, and the file is in the site once.
A note whose properties are not known always stays out, whichever rules are set: one that Obsidian has not read yet, as right after it starts, and one whose properties have a mistake in them, so that Obsidian shows them as text. A rule may be meant for such a note, and it cannot be checked. The step Look over lists these notes.
Ticks are for notes. A picture or another file that is not a note is never chosen by a tick, and it is not in the tree. It goes into the site when a note of the site uses it, and only then. So ticking the whole vault does not put the pictures of a private note into the site, nor a file that lies in a folder of private notes and that no note links to. To have a file in the site, link to it or embed it in a note of the site.
In the tree, a ticked note that a rule keeps out is crossed out, with the rule beside it.
A note that is not part of the site leaves nothing in it:
The same holds for what reaches the site without being drawn by Obsidian: a link in a property or in a heading is shown as its words. An address that opens Obsidian (obsidian://) is taken out, because it holds the name of the vault and the path of a note. What is written as HTML in a note keeps an address (href, src, a picture in a style) only when it leads to the web, to a place on its own page, or to a file of the site. A style rule of a plugin or a snippet that names a folder of the vault, or a note that is not in the site, is not copied.
The step Look over lists the links and embeds that are cut: those that Obsidian knows as links. An address written as HTML is taken out without being listed.
A build is what you looked over. If the vault changes between the list and the build so that other notes or files would go in, the build is not done, and you look again.
A name can still show. The build cannot know every way a name gets onto a page: the words of a link, a sentence that mentions the note, or what another plugin writes when a note is drawn, such as a query that lists notes. So after a build, the words of every page are looked through for names, and the dialog says which name shows where. The names are those of the notes that are left out by path or by property, and of the notes whose properties are not known, ticked or not. Not looked for: the name of a note that is out only because it is not ticked or lacks what a rule to take in asks for, and a name shorter than three signs. It changes nothing: whether a name may show is for you to say.
A site that is built as a folder (Written as), or an archive that is unpacked, is ready for it: every address in it is relative, and it has the .nojekyll file that GitHub Pages needs to serve all of it. Put the content of the folder into the repository or the branch that your pages are served from. A build of the same notes gives the same files, so a commit of the site shows only what has changed.
A site on GitHub Pages can be read by everyone. Look over the list before you build for it.
The site loads a note, and the text to search in, through a frame that is not seen. A web server that forbids every page to be shown in a frame, with X-Frame-Options: DENY or Content-Security-Policy: frame-ancestors 'none', keeps the notes from loading. GitHub Pages does not do that. On a server of your own, allow frames from the same origin: SAMEORIGIN, or 'self'.
The site looks like your Obsidian because a build copies the style sheets that your Obsidian has loaded: those of the app, of your theme, of your snippets, and of your plugins, also the ones a plugin makes with script, with the fonts they use. They are copied on your device at the time of the build. None of them is part of this plugin.
Some sizes and colors of these style sheets go by the system Obsidian runs on, as the roundness of buttons. The site has them as Obsidian had them where the site was built, wherever it is read: Obsidian on an iPhone or an iPad counts as on a Mac.
Those style sheets belong to their authors, and the ones of the app to Obsidian. Other plugins that publish notes do the same, but there is no written permission for it. Keep that in mind before you put a site where everyone can see it.
query lists lines of other notes, and one that starts with base lists notes and their properties, whatever they are.You need Node.js 24 or later.
npm install
npm run dev # rebuilds main.js on every change, but not for src/viewer: start it again
npm run check # type check, lint, and tests
npm run build # type check, then the main.js of a release
src/select decides what goes into a site. It knows nothing about Obsidian, so its tests run with plain Node.js.src/build has Obsidian draw the notes and writes the site. The zip archive is written by zip.ts, without a library.src/ui holds the dialog.src/viewer is the script of the site, which runs in the browser. It is built on its own and goes into main.js as text.How the site gets its notes. index.html loads the list of what there is, data/index.js, as a script. A note (data/n/<id>.html) and a part of the text to search in (data/s/<n>.html) are each a small page that holds its content as JSON. The site loads one in a frame that is not seen when it is needed, and the script app/frame.js in that page hands the content over as a message (loadData in src/viewer/dom.ts). Why so:
fetch is refused there. Showing another file in a frame is allowed, from a file and on a web server alike.To try a build, copy main.js, manifest.json, and styles.css to .obsidian/plugins/vault-to-site/ in a vault.