A simple, flat-file blog system using PHP and Markdown. No database, no admin panel, just write and publish.
Concept
Frustrated with bloated CMSs, I built a minimal blogging system that uses Markdown files as the database. Write in your favorite editor, commit to git, done.
Architecture
posts/
├── my-first-post.md
├── another-post.md
└── latest-thoughts.md
Each post is a Markdown file with YAML frontmatter:
---
title: Post Title
date: 2024-01-15
tags: [web, programming]
---
Post content here in **Markdown**.
The Code
Dead simple PHP script that:
- Scans the
posts/directory - Parses frontmatter from each file
- Converts Markdown to HTML using Parsedown
- Displays posts sorted by date
function parseFrontmatter($content) {
preg_match('/^---\s*\n(.*?)\n---\s*\n(.*)/s',
$content, $matches);
$yaml = $matches[1];
$body = $matches[2];
// Parse YAML into array
$meta = parseYAML($yaml);
return ['meta' => $meta, 'body' => $body];
}
Benefits
- Version Control: Every post is in git
- Portable: Just Markdown files, import anywhere
- Fast: No database queries
- Offline Writing: Write without internet connection
- Simple Deployment: rsync to server
RSS Feed
Auto-generated from the post files. Because RSS isn't dead.
Performance
With proper caching headers, pages load near-instantly. The entire blog can be served from a Raspberry Pi.