Kitaab

Obligatory: How this blog gets made

meta blog

published 2022-04-22 19:41

updated 2022-12-29 02:36

I never thought I'd be someone who creates an SSG but here I am. So I figure I might as well do the whole thing where I talk about how it works and stuff?

= Why Write an SSG? = Previously I was using Hugo and a theme, and though it worked fine as a website, I had to specifically choose to blog about things and that was really a chore when I already had Kitaab, so I needed a thing that would turn Kitaab into a website. Since there's lots of parts of Kitaab that shouldn't be public, I decided the only way this was going to work was if I wrote it myself. I started with Poonam, a small helper bot that can process Kitaab. One of the functions Poonam provides is sanitized and filtered notes that are fit for the public to consume. Certain tags get removed entirely, some words get censored but still published. Otherwise Poonam helps me keep Kitaab tidy, while also teaching me more about it.

Making the HTML

These files get consumed by Basant which is forked from Chisai which is written by Thomasorus. I only changed the templates around a little, but I did have to change the process it works through quite a bit (and it's in desperate need of a big clean up). It doesn't do anything too fancy. Parses my strange amalgamation of rst, md and wiki files, and then replaces them in an HTML template using jinja2

Deploying via Nix

Now because I'm a giant Nix nerd, as you probably know, I wanted this all packaged by nix. This turned out to be a little annoying since Kitaab is a private repo, and Poonam lives there, where as both Basant and Helm are public repos. Turns out I can add a private git repo as an input to a flake, and use it as part of my build process. Basant defines two packages, both the static site builder, and the output of running the site against Poonam. I can have these both in my Helm flake, tell Basant to use Helm's Poonam when building, and have a systemd job that triggers once a day to update the flake lock inputs in Helm. Now I have a reproducible website that I can easily deploy to any NixOS server I control. And that's exactly what I do, the job that updates the flake inputs also deploys my website through deploy-rs straight from Helm. This means that my private notes are never copied to any extra machines, and that my website automatically gets updated whenever I make changes in Kitaab without me having to do anything.

Hidden Gem

Sometime after doing all this, I wanted extra functions in my HTML. If I was generating it everyday anyway, why not add some randomness to the generation, and some functions to Kitaab? You may or may not have noticed that this page exists. Those words may look familiar, because the appear on the home page. I always wanted my website to be an ever shifting maze of densely packed information, sorta like gwern but more maze like and certainly less polished. I hope to add more features on my redesign.


Backlinks