Table of Contents toggle

Building My Publishing Pipeline in Obsidian and Cloudflare Workers

I keep everything in Obsidian; research, half-formed opinions, lecture notes. My blog posts live in the same vault as Bayesian A-B Tester.md and 3-Month Career-Ready Study Plan.md, because that’s genuinely where they get written. What I did not want was a publishing tool that treated my notes as raw material. I wanted the vault to be the CMS. This post is the story of getting there including the part where I built it wrong first.

Why write in Obsidian?

Because my notes are already the source of truth, and most blog tooling assumes they aren’t.

The appeal is mundane but real:

  • One place to write. No “copy this into a CMS and paste it back into my notes” loop.
  • The notes stay canonical. A blog post that lives only in Ghost becomes a second, competing copy the moment you revise the idea.
  • Wikilinks resolve themselves. [NeuralCard](/neuralcard/) in a draft can become a real link at publish time instead of a broken one.

Why not publish directly from Obsidian?

I tried to be honest with myself about this, and the answer is: Obsidian is a superb editor, but it is not a CMS.

What publishing properly requires that Obsidian doesn’t give you:

  • a preview of what the rendered page will actually look like
  • drafts and scheduling with a real publish date
  • per-post SEO, Open Graph, and Twitter card metadata
  • a media library with resizing and CDN delivery
  • somewhere to generate social cards
  • a URL scheme that isn’t pokharelsabin.com.np/Some Note Name
Obsidian Publish does solve most of this but it hosts on Obsidian’s infrastructure with Obsidian’s design, and it isn’t Hugo. I wanted the site to be mine: my theme, my markup, my build.

The other option was the classic one: keep the posts in Markdown, git push, let CI build them. That works fine, and it’s what most static sites do. What it doesn’t give you is a publish action — a deliberate, auditable moment where a draft becomes live, with media uploaded and a build triggered. Every publish became a commit, and I was always one git add -A away from shipping something half-finished.

Why I started with Ghost

I picked Ghost deliberately, and for the right reasons at the time.

Ghost fit the shape of the problem almost exactly: Markdown bodies, scheduled posts, a headless Content API, draft/published states, a real editorial workflow. Reading its docs, I thought “this is a CMS built for people who write, and it has an API, so I can drive it from my vault.”

So Witch; my Obsidian plugin was originally a Ghost publisher. It held an admin API key, minted a JWT, rendered markdown into Ghost’s HTML card format (kg-* wrappers and all), and pushed the result. Version 1.2.0 shipped that way.

The gap that needed filling

Ghost worked, and then I noticed what it actually was: a second place my content lived.

The problem wasn’t features. The problem was that Ghost was a database I had to keep alive, and every property it had was a property I’d inherited:

  • It needed a server. A running instance, upgrades, and backups — for what is fundamentally a folder of Markdown files.
  • It stored HTML, not Markdown. My vault was the source of truth, so Ghost was a lossy projection of it. Every publish round-tripped my prose through a renderer I didn’t control.
  • It had its own admin UI that I never used, because I wrote in Obsidian. Dead surface area, still a liability.
  • It fought the static-site goal. What I actually wanted was Hugo: fast, cacheable, no runtime. Ghost was the opposite — a dynamic app rendering pages per request.
  • A theme layer I’d have to maintain. Ghost’s themes assume Ghost’s DOM. Escape it and you’re forking.
The lesson: I picked a CMS because it was a good CMS, instead of asking which part of “CMS” I actually needed. I needed a publish action and a content store. I did not need an editorial database, a theme layer, or a rendering engine.

Why a Worker instead

I needed exactly three things: somewhere to put a published file, a way to trigger a rebuild, and a way to know the last build succeeded. That’s a handful of endpoints, not an application.

So I deleted Ghost and built witch-worker — a small Cloudflare Worker that is a content API and nothing else. It stores published content in R2, serves it to the build, and pokes Cloudflare Pages when something changes.

The Git history of the plugin says it plainly: v2.0.0 “Reworked Witch from a Ghost publisher into a CMS for static Hugo sites.” The Ghost Admin API, the JWT, the HTML card pipeline, and the markdown-it dependency all went away. Markdown bodies now publish as-is and Hugo renders them.

The full pipeline

Publish

PUT content/… + Bearer token

Write object

POST /api/build

Trigger build

sync-content.js

pagefind + hugo --minify

Obsidian vault
Site/ folder

Witch plugin

witch-worker

R2 bucket: portfolio

Pages build hook

Cloudflare Pages

content/ in Hugo repo

Static site on the edge

The publish transaction

Cloudflare PagesR2witch-workerWitch pluginCloudflare PagesR2witch-workerWitch pluginSabin (Obsidian)Publish note1PUT /api/content/blog/<slug>.md (Bearer token)2Length check + timingSafeEqual3PutObject4OK5200 { ok, key }6"Published"7POST /api/build8Write meta/build.json9GET /api/manifest10sync-content.js → hugo --minify11Sabin (Obsidian)

Auth is one shared bearer token, compared with crypto.subtle.timingSafeEqual after a length check. Every route requires it. That’s the entire security model — which is honest about how little attack surface a publish-only API has.

The worker is only involved at publish time and via cron. The served site never calls it at request time.

The parts that turned out well

R2 is a content store, not a CMS. One bucket, portfolio, with content/, images/, media/, and generated og/ cards under it. Keys map 1:1 onto paths in the Hugo repo, so the sync step mirrors them:

content/blog/<slug>.md          # posts
content/<slug>/_index.md        # static pages: about, contact, privacy
site.json                       # site-wide settings, merged into config

The Worker works with any Hugo site. It has no opinion about the Witch plugin. Drop in scripts/sync-content.js, point it at the worker, set two env vars. That was an accident of separating concerns, and it’s the part I’d keep if I started over.

Scheduling is nearly free. A future published_at keeps the post draft: true at sync time. A cron every 5 minutes rebuilds only when something is actually due — it tracks the earliest pending published_at in meta/build.json, so an idle tick costs one list and one read. No file reads, no rebuild.

The dashboard shows build truth. GET /api/status returns the last build result, so the plugin can say “last build · ok / failed” instead of shrugging.

Frontmatter stays readable. title, slug, excerpt, featured, meta_title, meta_description, canonical_url, og_*, twitter_*, published_at, status.

Publishing is a deliberate act. Draft notes are never uploaded. There’s a Publish button, an Update button for posts already live, a change indicator if I’ve edited since the last publish, and bulk publish for when I’m clearing a queue. The site is production-by-default and the vault is the only draft state.

The parts I’d do differently

I want to be fair to my past self here, because the Ghost detour wasn’t wasted it taught me what I actually needed.

  • No second writer. The worker is a publish API, not a multi-user CMS. If a second person needed to publish, I’d be back to thinking about permissions and a database. This design assumes one author.
  • Vendored sync scripts drift. sync-content.js exists in two repos and they must stay byte-identical. The rule is documented; the failure mode is a silent content bug.
  • Local dev needs the worker running. pnpm run dev plus a local Hugo server. Fine when it’s one repo, more friction as the stack grows.
  • One runtime quirk leaks out. crypto.subtle.timingSafeEqual is Workers-only, so the test suite shims it over node:crypto. Small, but it’s the kind of detail that reminds you the Worker is the only place this code truly runs.

What this gives you

A pipeline with no database, no runtime API, and no second editor:

  • Version control — the vault is already in git, so every post has real history
  • Markdown end to end — no HTML round-trip, no lock-in on a renderer’s opinion of your prose
  • Flexibility — the Worker serves any Hugo site; the plugin is replaceable
  • Zero idle cost — static output on the edge, no origin to keep warm or patch
  • Ownership — the theme, the markup, the domain, the deploy

Newsletter

At the limits

Occasional letters on math, AI, and the tools I build. No spam, unsubscribe any time.