Blog post about writing blog software

A classic tale, with nothing new in it

By Saphire Lattice - posted

So, I have had a bit of an issue. This entire site was written on my own, and that's fine. It was handwritten, which is fine. Having more than one page added things to work on, but that's also fine!

I added integrity parameter to every JS and CSS asset, and this was not a good idea. It caused me constant grief, having to go and do global search and replace in every file for old hash to replace with new. But hey, I said, it's neat and secure! And removing it requires effort. So it stayed. All while I'm still handwriting every page. Oops.

Then I decided to slap a silly system I called hotswap.json that makes pages load dynamically. Look, it just sounded cool and I wanted to see if I could implement one in a way that doesn't also break when you disable JS. So far no complaints on that! This was a big mistake.

The system itself is simple, it just requests a hotswap.json file whenever you visit some page on this site. Simple, etc. Though probably should be nixed, as it maybe makes page nav to anything without it take longer. What was not simple is updating it.

Updating each such file was... relatively trivial. Just change the metadata to match the handwritten files. Easy! Just ah, there are already three different sets of metadata properties and this added another one to remember. But okay, that got updated. But oh dear the actual page content got updated! That part was hellish. I have to grab the page, copy around a specific element, and base64 convert it. Easy, right? Uh yeah this needed doing on every single change and I often found myself forgetting changing that.

Another issue is that the site is all sitting in a git repo. Published it through GitLab Pages initially, then moved to own thing. Made a little script to just dump it into target directory after a while, though at first just used it directly from workdir. Right now it's still a git post-update hook, but with a self-written C# program. Oh yeah, those files that should have been autogenerated? Yeah those were just in git. Yup. Gross, I know.

The overall problem is: holy shit this was all so tedious. Updating the site in any amount that was not tiny uh. It sucked. It was miserable and brought me nothing but pain every time I did it. If I wanted to update the overall template of it? HA. Ha. Good joke, nice one. So I avoided any significant work on it and let it gather dust.

So I've made a C# based static site generator using custom HTML templating thing. Inspired a bit by Vue.js, I guess. It's not solved everything, there's still a fair bit of manual work. But biggest issues have been addressed. Metadata is not a pain to write anymore - that's in a template. Hotswap stuff is now automatic, where applicable. And I have an actual base template that covers the entire site! Woo! It even lets me see the site as it would get parsed, without having to regenerate everything all the time!

It still needs work, I want to designate slots where stuff will go, I want slightly more complex templating capability. The blog posts would greatly benefit from it! A lot. And there's still no automatic navigation generation. What you see on every page is there in the source files.

As for integrity attributes? I just deleted them. They were not necessary. This is a personal website with no "user generated content" to speak of. There's no CDNs being used. Any compromise of the "assets" will lead to compromise of the site itself so thoroughly that this silly attribute will prevent nothing. I could have them autogenerated now, but there's no real point to it.

P.S. So much webdev software has no clue that <p> paragraph tags don't require a closing tag in many cases. But alas, vscode ended up listing a billion nested paragraph tags even though this is against the spec to exist. Most HTML elements being "inside" of the paragraph will cause it to get cut up by it. And the cut off text will not be in a paragraph anymore. Fun.


< Back to my now somewhat templated site