Urgent.News

What's breaking now, across thousands of outlets.

Tech

A new, bespoke static site generator to replace Jekyll

My blog was initially a blosxom (Perl) site hosted on a virtual private server. In 2011, I transitioned to GitHub Pages, where Jekyll (Ruby) generated the static site on the GitHub server. I found Jekyll to be a no-brainer choice, as it was easier, faster, and cheaper. After 15 years of using Jekyll, I recently replaced it with a new, custom-built static site generator called ssg, which is written in "C with templates" C++20.

The source code, approximately 8K lines long, closely follows my personal coding style, including templated arenas and slices, zero dependencies, and a libc-free core. The generation of my blog takes only 150 milliseconds on my MacBook, faster than Ruby would even reach Jekyll's entry point. Visually, there are minimal changes; the HTML remains semantically identical, and I adapted Rouge's syntax highlighting CSS selectors to use my style sheet unchanged.

By maintaining complete control over the codebase, I could easily modify the C++ source to address syntax highlighting, bug fixes, and support for new languages, particularly assembly (WAT, AT&T, Aarch64) and QBasic. The upgrade involved three steps: (1) fixing 19 years of accumulated site bugs that Jekyll had silently tolerated, (2) introducing the new generator, and (3) deleting Liquid templates and pre-generated tag pages, which are now dynamically generated with original feed UUIDs preserved.

Simultaneously running Jekyll and ssg allowed for side-by-side comparisons from the same site source. This process took time, but I believe that ssg, with Liquid templates, would still outperform Jekyll. Historically, Jekyll was slow until version 4.0.0 in August 2019, but performance issues persisted. The final Jekyll version of my site took about 2 seconds to generate on my MacBook, while ssg completed the task in 150 milliseconds.

The deployment process with Jekyll was problematic, especially when attempting to match GitHub Pages configuration. Running Jekyll on Windows was an exercise in frustration, and I had not generated my blog on Windows in part due to the deployment challenges. Switching to macOS clarified the situation, as I now had a more reliable development environment.

The C++ implementation of ssg requires only a C++ compiler, meaning no additional development tools are needed once it's built. The single-file compiled program can be copied to another system and run directly. On Windows XP, the build time was around 150 milliseconds using the -O0 build, making it feasible to recompile the generator for each site regeneration.

In the GitHub Actions pipeline, the generator runs automatically on push, maintaining the previous functionality. Overall, ssg proves to be faster than Jekyll, with a debug build being faster than a release build. I do not intend to make ssg a general-purpose static site generator, as its sole purpose is to serve the specific needs of my blog.

The project was years in the making, and while it took approximately 20 minutes to write the detailed prompt, the Opus 5.5 model in Claude Desktop produced ssg in its current form, free of bugs.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at nullprogram.com →

More in Tech

More from Monday 5 October →