This website is generated using miu, a very simple static site generator written from the ground up. This page serves as a high-level documentation of how the generator works and the thoughts that went in when creating it. It was written in hopes that it might be useful for someone attempting to or already building one such program. It was also written for myself as a way of reflecting about it and to serve as an assistant for future iterations.
miu is both a Japanese given name (美宇) and a pronunciation for the greek letter μ. The letter μ is used as a unit prefix denoting a factor of 10−6 (one millionth) or, in other words, it’s very tiny. It’s also the coefficient of friction, which is the principle by which some (electro)static generator machines work, so it fits the theme of static (site) generators nicely. I guess a loose translation could be “a very tiny thing that generates static stuff”.
Here’s a high-level overview of the different modules that comprise the generator:
Module | What it does | Simpler alternative | Implementation in miu |
---|---|---|---|
Template engine | Combine templates and sometimes also data to produce pages | Copy and paste code and data | Go’s standard library |
Markdown renderer | Transform markdown (which is more succinct) to HTML | Write everything directly in HTML | Pandoc |
Image processor | Optimize image sizes, process images in a desired way | Optimize images manually | ImageMagick and cwebp |
Cache | Speed up the build process by rebuilding only what’s been changed | Wait longer | Custom module |
Build pipeline | Execute the modules in the right order, to the right files and output to the right places | Execute modules and move files around manually | Custom module |
In miu, content is stored as plain-text markdown files aiming for easy migration and enhanced longevity. Templates provide both a way to reuse sections such as the header and a way to generate special pages such as the index. The build pipeline orchestrate things acting like the controller in the modern understanding of the MVC architecture.
Step by step: