David Piper
🚧 Rebuilding this site in my spare time.

Origin

1 Jul, 2020 • 2 min read

Welcome to my blog! This site is built with my own custom site generator, so I thought I'd use this first post to describe how it works.

There are three GitHub repos for this blog. It could potentially be condensed into a single repo but it felt cleaner to split it up into its logical parts.

  1. The Github Pages repository
  2. The Blog Reel
  3. The Site Generator

The Github Pages repository

This is what you're seeing - it's the repo that contains the website tree. Github Pages now supports HTTPS with custom domains too! 🎉

The Blog Reel

This is a flat repo of markdown files with the individual posts. They're named in a way that forces both alphabetical and chronological order - for example, this file is named 00001-origin.md. There's also a folder called assets, which will hold what it says one day soon.

The markdown files actaully start with a bit of HTTP-esque metadata for things like url, title, tags, publish date, etc. Most of this is really only needed to keep the Atom feed happy.

Then there's an empty line, and then the markdown starts.

The Site Generator

The site generator repo contains scripts to build the site from the blog reel. It pulls the blog reel down, feeds it through about 300 lines of Python and generates the full HTML tree for the blog.

The markdown to HTML conversion happens in a single line. The rest of the Python code is a combination of extracting data from the raw posts and using a poor-man's HTML templating system ~definitely not just find-and-replacing pre-defined symbols~ to generate the home page, the Atom feed, and all the blog post pages, with sequential links.

The full HTML tree is then copied into the Github Pages repo, committed and pushed.

And that's it!