← Back to weeks

Week 13 | A Useful Tool For No One But Me

This week is a another command line tool built pretty much just for me.

The site you're reading right now is made using a series of bash scripts and php files that I hacked together to get a "static site generator" built. I wanted something simple when I built this site, and I wanted to avoid as much tooling as possible. It needed to be simple, quick and free of non-system tooling. I'd add to the scripts as the site grew, if it needed to grow.

Even though PHP isn't my favourite, or even most-used, language, it's pretty stable, widely supported, and has a lot of useful built-in functions. Especially for going from PHP -> HTML, which makes sense considering its origin story. I find myself reaching for it when I need a slightly dynamic site with some form of templating but needs to be quick.

A downside to my home-grown static site generator is that it didn't have an automatic way to create a sitemap, so most of my site hadn't been indexed by Google. As I kept adding sections to it, and started treating it more like a living piece of myself on the web, the more indexable I wanted it to become. So, I decided it would be fun to create a sitemap generator for the build artifacts of my site.

Since I've fallen in love with Clojure, I figured it would be a fun opportunity to use it again! The design specs were simple. It needed to read from a directory that contained the build artifacts produced by a bash script that converts my PHP laden mess into HTML files. This bash script runs whenever I deploy to the main branch of this site's repository. At the end of the build script, I added a line to generate the sitemap file and place it at the root level of the public folder.

Writing this script has furthered my love of working with Clojure. I'm starting to get more productive with it, and need to bend my brain a little less to think in a purely functional way. It's wonderful.

You can see the source code on GitHub here: https://github.com/graingiant/static-site-sitemap-generator