Carl's blog

Rehosting my website + static site generator

I've gone back and forth for a while on whether my main website cactusdan.com should be a professional website or a personal website. So for years it's been in kind of a superposition of both, not terribly personal or professional so unfit for either purpose. Since my employment has been stable I've finally settled on just making it a personal website. If I want a professional website in the future I'll just buy a new domain or use kralinc.github.io bare.

Because of this change I felt a change in host was in order. I don't feel like having my whole git history of every change I make able to be scrutinized publicly, so I moved to a different git provider with a private repo. Then for the site itself I switched from github pages to cloudflare pages. This is partly motivated by github as of writing this maintaining zero nines of uptime. That and maintaining a little more separation between my website and my github. Just personal preference.

I want my site to be as easy to move and access as possible. I'm not going to make my personal website with npm install 2 billion gigabytes of bullshit and 9999 MB js downloads into your browser. The most un-vanilla thing I use right now is bootstrap, and sometime down the line I'm just going to write my own CSS file to slim it down to only the style classes I actually need from it. Right now one of my pages is about 2kb and bootstrap is 30kb. That's so unnecessary.

Despite all of that it's been getting tedious to add new content to my website. After deciding to make my bookmarks page in plain web technologies I found myself needing to copy-paste between 5 different html files whenever I wanted to change something about the base layout. I added a footer, and that footer had to be added to each page by hand. Something had to change.

I considered using web components. It's a vanilla web technology that's built into every web browser, but requiring javascript to render what is spiritually a static site felt wrong. Like using a flamethrower to cook a marshmallow. Sure it's more convenient from the development side, but it requires client re-rendering of the same content every time. This is the perfect use case for a static site generator.

In the interest of making everything as easy to move and understand for me as possible, I made my own instead of using any sort of off the shelf solution. My needs are simple enough that some basic text-replace with some loops does the job. So now each page is specified in a json file. It's got a title, links for the header, description, links for the body, plus any extra custom html I want to insert in there. The format for the links and pages are specified in plain html files. It also populates the footer so you can see what date I last updated the website. All I have to do now is run my generator in python and it slurps up the json and spits out the formatted html files. Now when I want to change the overall format I don't have to manually edit a ton of files anymore, and the site is static for users accessing it. Everyone wins!