App Dev · · 1 min read
A blog with no database
Why this site is Markdown files and a few hundred lines of PHP, and what that buys over a CMS.
This blog has no database. Posts are Markdown files in a folder, the front matter is six lines of key-value pairs, and the whole thing renders through a small PHP front controller. Backing it up means copying a directory.
What a database would have cost#
A CMS brings a schema, migrations, a query layer, a cache, and a security surface that needs patching on someone else's schedule. For a blog that publishes a few times a month, none of that pays rent.
// The entire storage layer, more or less.
foreach (glob(POSTS_PATH . '/*.md') as $file) {
$posts[] = parse_front_matter(file_get_contents($file));
}
usort($posts, fn ($a, $b) => $b['timestamp'] <=> $a['timestamp']);Reading forty files per request sounds wasteful until you measure it. The OS page cache holds them all, and the whole listing renders faster than a single unindexed query would.
Where the line is#
Flat files stop being the right answer when you need:
- Concurrent editors who can conflict
- Relational queries across content
- Thousands of items, where scanning a directory turns into real work
None of those are true here, and if one becomes true, Markdown files import into anything.
The parts worth building carefully#
- Front matter parsing — strict, boring, and forgiving of trailing whitespace.
- Slug and filename discipline — the date lives in the filename, the URL does not.
- A real Markdown renderer — including tables, because technical writing needs them.
Everything else is a view.