Webgen blog generator

Published 2024-05-22


I have a tendency to 'rebuild' my computing devices, sometimes the hardware, more often the software stack. A few times a year I'll reinstall windows, linux, freebsd, depending on the mood and what I need to get done. This also involves reinstalling the various tools I need, graphics packages, editors and so on.

Annoyingly, this also means rebuilding whatever tools I'm using for managing websites. In particular I find it frustrating to set up tooling for my own personal sites. Ideally publishing to the web shouldn't involve anything more than the most basic text editor and a web browser, but there are usually reasons why this isn't ideal. As soon as you want features like links between pages, tags, any kind of hierarchy or organisation, the workload multiplies. These are all possible manually, but better to be done quickly and accurately by the machines. Hopping around between processor architectures and operating systems, I run into compatibility problems. "This version of web publishing software isn't available for your operating system. This version of 'dependency' doesn't work on your processor type" etc. So I decided to make a simple, portable site generator that will work everywhere I could possibly want to use it, and work fast. This last requirement is particularly important to me as I'm currently doing all my work from a very modestly powered raspberry pi 'tiny computer', where visual content editors tend to be a bit slow and unwieldy.


I didn't even waste time on coming up with a nice name. This is a 'website generator', webgen. I bashed it out over two evenings, sticking to the C programming language. C isn't ideal for easy text processing, but the results are fast and can be compiled on any almost device from the last 30 years (probably?). I'm quite sure it won't work in a very ram restricted environment, but being simple and self-written, I can fix any problems I encounter in restricted future environments. There's also nothing in the way of server-side requirements, no special executable code that needs to run on the server as with PHP, ASP, node, and nothing that has to run in the client browser such as javascript. Just C parsing markdown and generating HTML.

Including Markdown

I was previously using Publii to edit my site. Before that Hugo and Pelican. All of these supported markdown files, a simple way of annotating text that can be later converted to html. But annoyingly, if the author was unfortunate enough to misplace (or delete in anger) the original markdown documents, there was not a good way to turn the generated site pages back into markdown documents. For this reason, when Webgen publishes a website, the original markdown files are included in the output. If i were to lose the local verion of my site data, or want to switch to some other site generator with markdown support, I would only need the content of my published site directory, which includes all the media and markdown files needed for any other generator to build a site.

Webgen: closed source??

Even though I've written Webgen to be 'fast and scrappy' there are parts of the code that are honestly just a little too embarrassing to share. Perhaps I'll clean it up and put it somewhere, but more likely not. It's a tiny tool that does one job. This page (or feed!) that you're reading was generated with it, at least originally, and if you've read this far then webgen has obviously worked well enough. Perhaps I could open source it under a 'no feedback permitted' license ;)

Webgen running inside vim


Tom 'voxel' Purnell