I love the promises made by static website generators. The ability to write your website piecemeal without handwriting or copy-pasting entry content lists or repeated elements makes for a fundamentally better experience than writing an entire website by hand. I don't envy anyone who's set themselves the task of writing a website from scratch without the use of external tools, and I've done just enough of it myself to last me for some time.
The problem is I don't want to use any of the static website generators which are popular and readily available.
I don't dislike them, don't get me wrong. Using Jekyll or Hugo or whatever else you might choose is perfectly fine. They're solid tools, used by a great many people to great effect. I just don't like Ruby or Go much, let alone writing my templates using Liquid or Go's html/template
module. And I don't like my tools to create strong requirements about what kind of website I'm making unless I dig through how to change the default settings.
Obviously, instead of taking the time to learn how to twist these industry standard tools to my desires, I decided the solution was to spend even more time making my own.
I like to write tools using unadorned, pure Lua code. If a codebase is going to be entirely dependent on a tool, to the extent that it becomes all but unusable when the tool is not present, I'd prefer that the tool is as easy to get working as possible. Admittedly, as much as I love it Lua isn't the best lanaguage for this. Lua is a simplistic language by design, and even on Linux external libraries which bind to better tools can be irritating to get working correctly as soon as you have multiple versions of Lua installed. Using a language like Python or (much to my chagrin) Ruby which has better native libraries would make this an easier task, which is why most SSGs aren't written in languages like Lua. But there's another excellent language for general-purpose tasks which I already have installed on all of my computers which Lua can largely interoperate with: Bash.
I've been using Linux almost exclusively for a number of years now, and one of the things I really love about it is how incredibly versatile the command line is. Windows has its own scripting languages, but Linux forces you to learn and gives you more and often better tools. That can be a double-edged sword, admittedly, but it means also that any programming language which has the ability to open a shell process and get input back from stdout has access to a number of massively useful and well-documented utilities.
This entire website is powered by the find
utility which comes free with using a Unix operating system, among other important commands. It's both possible and relatively simple to take the output from find
and turn it into an entire semantic tree representing the file structure of my website as objects in memory. I built my tree to be traversible using Unix-like relative directory notation. Doing that allows me to, for example, get a list of every file in this website's blog/
directory and turn them into an index and an RSS file. But I can also create a generic RSS generation script and drop it into any folder on this website, or do the same thing for tasks like the buttons I have at the bottom of every page.
The other thing which makes this website tick is preprocess.lua(https://github.com/DimitriBarronmore/preprocess.lua), a text preprocessor I wrote myself for the initial purpose of metaprogramming my other native Lua programs. It was originally created for Luxtre, my hand-written dialect of Lua, but the current standalone version has been reworked and given a number of extra features. For example: custom ""frontmatter"" metadata, which I use to set templates, page titles, and RSS dates and descriptions. Using preprocess.lua I can unroll loops, create and use adaptive templates, reuse content between pages with includes, and a number of other things besides. All the stuff I'd be doing with Jekyll or Hugo, just using Lua scripting instead.
I'd like to take a moment here to thank Marcus 'ReFreezed' Thunström for the existence of (and Alex Larioza for continuing to maintain) LuaPreprocess(https://github.com/GamesRightMeow/LuaPreprocess), and Étienne "Reuh" Fildadut for putting together Candran. Candran was my direct inspiration for the creation of Luxtre and for most of the syntax in preprocess.lua, and LuaPreprocess was responsible for showing me that I was overcomplicating a few things. I doubt whether any of the parties involved will read this, but if you do, hey, thanks.
An extra shout-out to luamd by Calvin Rose et al, my current solution for alleviating some of the pain of writing text in HTML by way of markdown files. I had initially planned to plug Pandoc into this toolchain to give me the most flexibility possible, but for the moment I've gone the simpler course of using a plain-lua markdown processor. It seems to have particular difficulty understanding links to URLs which contain underscores, but so far it's working well. Maybe I'll contribute upstream sooner or later.
Laying out the ingredients to create this site may make it sound easier to put together than it actually was. Part of that is my own fault- overscoping made this project take longer than I might have liked, at risk of increased flexibility I may never need. But however hard the journey may have been I now have this tool in my hands, and the advantage of writing it plain is that unless Lua and Unix cease to operate there is nothing in this world which can make it stop working.
You might have noticed if you're reading this at the time of writing (or if it hasn't substantially changed in the time since) that this website is very "function over form". The main reason for that is if I worried myself with form, I wouldn't have any function. I'm not an especially talented web designer as yet, and while I can look at a website and see that it looks cool I can't necessarily sit down and design one. But the tools I've given myself are flexible enough that I should be able to do whatever I like with them from here out. If I decide to overcomplicate this website in the future I can do so easily. After all, it's still 90% plain HTML and markdown.
The title of this post comes from the book Range by David Epstein, which I've been reading recently. There isn't much meaning to that, I mostly just thought it sounded cool. But I'd like to think that in the spirit of generalization versus specialization I've still picked up a couple of interesting skills while doing this by hand. For one thing, I understand how RSS and Atom work a bit better now.
If you'd like to use this tool for yourself, you can pick it up on GitHub(https://github.com/DimitriBarronmore/lua_ssg).