# Obsidian Headless Publish Setup
You can publish PubProjects from a Grok Bot routine, without clicking through the Publish dialog, with **Obsidian Headless** (`ob`). It is Obsidian's official command-line client, still in open beta. These steps are for Enceladus (Windows).
Official docs: [Headless Publish](https://obsidian.md/help/publish/headless), the [obsidian-headless package](https://www.npmjs.com/package/obsidian-headless), and the [Obsidian CLI](https://obsidian.md/help/cli) for the app's own publish commands.
> [!warning] The big caveat
> You currently choose what goes on the site with the Publish checkbox in the app. That choice is stored on the site, not in the notes. `ob` does **not** read that checkbox. It selects files from the `publish: true` / `publish: false` property in a note (this takes priority), from include and exclude folders set with `publish-config`, and, if you pass `--all`, from files that have no publish flag. A first run could add or remove the wrong notes. Always dry-run first, and compare the list against the live site before anything is published for real.
## 1. Check Node, then install `ob`
`ob` needs Node.js 22 or newer. Enceladus already has Node v24.19.0 (via nvm4w). Confirm it in a terminal:
```powershell
node -v
```
What this does: prints the Node version. You want `v22` or higher.
Install the headless client once (you also need an active Obsidian Publish subscription):
```powershell
npm install -g obsidian-headless
```
What this does: puts the `ob` command on your PATH. When this note was written, Node was present and `ob` was not yet installed. If a new terminal can't find `ob`, close it and open a fresh one so PATH updates take effect.
## 2. Log in yourself
Run this in your own terminal on Enceladus, not in a bot chat and not from a script:
```powershell
ob login
```
What this does: prompts for your Obsidian email and password, and for a 2FA code if the account uses it. If you are already logged in, it just prints your account info.
Do not pass `--password` (or `--email`) on the command line, in a routine, or to a bot. Never paste your password in chat.
After a successful login, `ob` stores an auth token on this computer. Official docs do not list the exact file path. On Windows it is typically `%USERPROFILE%\.obsidian-headless\auth_token`. CI setups can also use an `OBSIDIAN_AUTH_TOKEN` environment variable. Never paste that token or the file contents in chat, and don't put them in a script a bot can read. `ob logout` clears the stored file.
## 3. Connect this vault to your Publish site
```powershell
ob publish-list-sites
```
What this does: lists the Publish sites on your account, including each site's slug. Copy the slug for the PubProjects site.
Then connect the vault. Replace `<slug>` with that value:
```powershell
ob publish-setup --site <slug> --path "H:\My Drive\Obsidian\PubProjects"
```
What this does: links this local vault to that site so later `ob publish` commands know where to send changes. You can add `--json` if you want machine-readable output.
## 4. View the current settings
Run these with no change flags, so you only look:
```powershell
ob publish-config --path "H:\My Drive\Obsidian\PubProjects"
ob publish-site-options --path "H:\My Drive\Obsidian\PubProjects"
```
What this does: `publish-config` shows the include and exclude folders for this vault. `publish-site-options` shows the site name, home page, and display options. Don't change either until a dry run (next step) looks right.
## 5. Always dry-run first
```powershell
ob publish --path "H:\My Drive\Obsidian\PubProjects" --dry-run --json
```
What this does: compares local file hashes to the live site and prints the pending new, changed, and deleted files as JSON, without publishing anything. Official npm docs say most `ob` commands accept `--json`, and that without `--yes` the command only reports pending changes.
Read that list carefully, and compare it against the live published file list before you go further. Watch especially for:
- notes that would be added even though you never ticked Publish
- notes that would be removed even though they should stay
- the 70 Comic Books originals that used to live under `Comic Books/_Original JPGs/` (they were moved out of the vault on 2026-11-22). Those should show as deletions, which is what you want.
### Making the selection explicit
Because `ob` does not use the app's checkbox, the selection needs to be spelled out before any unattended run. Two options:
**(a) Set include or exclude folders** with `publish-config`. You can pass `--includes` and `--excludes` as comma-separated folder names, or an empty string to clear a list. Look at the current config first, then change folders only when a dry run matches the site you want.
**(b) Add `publish: true` to notes that should be on the site.** `ob` treats this frontmatter flag as the highest-priority rule. This needs your explicit OK. Bots must not add or change the `publish` property unless you say so. The never-publish notes already have `publish: false` (and `dg-publish: false`), which is what we want: those stay off the site.
Do **not** use `--all` on this vault. That flag includes files with no publish flag, which is most of your notes, and could publish far more than the checkbox currently allows.
## 6. Publish for real
Only after the dry-run list looks right:
```powershell
ob publish --path "H:\My Drive\Obsidian\PubProjects" --yes
```
What this does: uploads new and changed files, and removes files that were deleted locally. That's how the 70 Comic Books originals would come off the site. `--yes` skips the confirmation prompt, which is what a routine needs.
Before you run it, close Obsidian or let it finish saving, and wait until Google Drive on Enceladus is fully synced, so `ob` does not publish a half-written file.
## 7. Automating it with a Grok Bot routine
A reasonable Sunday flow, once setup is done:
1. Run the weekly vault check and the web-list refresh as usual.
2. Confirm Google Drive is idle and Obsidian is closed, or at least fully saved.
3. Run the dry-run command above and report the new, changed, and deleted counts, plus anything surprising.
4. Stop there until you approve.
5. Only then run `ob publish --path "H:\My Drive\Obsidian\PubProjects" --yes`.
Later, if you trust the dry runs, the same routine can publish automatically. Until then, keep the approval step.
Digital Garden is separate. The weekly sync still mirrors the Publish site into `dg-publish`. The `ob` commands in this note only talk to Obsidian Publish.
## 8. If the wrong files go up
- Unpublish them in the Obsidian app's Publish dialog. Or, with the app open, use the app CLI's `obsidian publish:remove` on those files (see the next section).
- Fix the selection (folder includes/excludes, or `publish` flags after you've OK'd that approach), dry-run again, then publish.
- To disconnect this vault from the site without deleting the site or unpublishing files:
```powershell
ob publish-unlink --path "H:\My Drive\Obsidian\PubProjects"
```
What this does: removes the local link between this vault and the Publish site. It does not take files off the site and does not delete the site.
Headless is still in open beta, so command flags may change. If something fails, check the docs linked below before changing a routine.
## 9. Alternative: the app's own CLI
If you'd rather not use Headless, Obsidian 1.12.7 or newer has a built-in CLI. Enable it in **Settings → General → Command line interface**, then open a new terminal. The Obsidian app must be running.
```powershell
obsidian publish:status
obsidian publish:add changed
```
What this does: `publish:status` lists publish changes. You can add `new`, `changed`, or `deleted` to filter, or `total` for a count. `publish:add changed` publishes all changed files.
Other useful commands: `obsidian publish:list` lists published files (`total` returns a count), `obsidian publish:site` shows the site slug and URL, and `obsidian publish:remove` unpublishes a file (add `file=` or `path=` to pick one; the default is the active file).
This route follows the same Publish-dialog selection you already use, because it talks to the running app. It is a poorer fit for an unattended routine, because Obsidian has to stay open.
## Sources
- [Headless Publish](https://obsidian.md/help/publish/headless)
- [obsidian-headless on npm](https://www.npmjs.com/package/obsidian-headless)
- [GitHub: obsidianmd/obsidian-headless](https://github.com/obsidianmd/obsidian-headless)
- [Obsidian CLI](https://obsidian.md/help/cli)