A blog without a database
Every blog I have built before this one started with a posts table, an admin
form and a WYSIWYG editor. Every one of them ended the same way: the editor
produced HTML I could not grep, the table needed backups, and writing a post
meant logging in somewhere.
This site stores posts as Markdown files under content/blog/. A post is a file,
a commit and a pull request. That buys a few things I did not expect to care
about as much as I do.
The content is versioned with the code
A typo fix is a diff. A rewrite has a history. When a post references a snippet from one of my projects, both move together and nothing goes stale silently.
There is no admin surface to secure
The attack surface of this site is a router and a Markdown parser. There is no login form, no session to steal, no privilege to escalate. The deployment is read-only as far as content is concerned.
Caching gets simple
Parsing Markdown on every request would be wasteful, so the parsed objects go into a cache keyed on the filenames and their modification times. Editing a file changes the key, which means there is no invalidation logic to get wrong — the old entry is simply never asked for again.
What it costs
Two things, honestly:
- I cannot write a post from my phone.
- Scheduled publishing needs a deploy, not a timestamp.
Neither has bothered me yet. If the second one ever does, a date in the future
plus a check at render time is a far smaller change than a database would have
been.