I've helped quite a few people set up Wordpress blogs (e.g. Urban Flute Project) over the years. Wordpress is a very easy-to-use platform with tons of plugins but I wanted something simple for my own blog.

I looked into existing static blog generators (viz. Jekyll) but they were too complicated (or maybe I just didn't look into them enough). Not-invented-here syndrome is something all programmers should avoid but I just couldn't resist making my own static blog generator.

The source code for the version powering this site as of September, 2013 is available here:

It's not the prettiest code but it does the job. It's fast and uses very little memory.

_generate.php is the program that generates everything. Just run it and it'll build all of the static HTML.

The system works by reading the files in /_source that contain the blog posts as pseudo-HTML files (see image below for what this file looks like in BBEdit). The posts are transformed into files and written to directories corresponding to the slugs set out on the second line of each file.

The main index and sitemap files are then written to the root directory.

/_template has the template files that are used to generate the blog posts.

_generate.php will delete any directory that doesn't begin with an underscore.

I considered using .htaccess to remap subdirectories but I don't see any downside to actually creating the directories.

Blog posts are written as files with four or more lines. The first line is the title, the second is the slug (directory), the third is the date and any following lines will be shown as paragraphs in the body of the post.

The design is inspired by Svbtle.

Here are two follow-up posts: “Automating Publishing” and “More About Automating This Blog”.