breaking my head building forge

Init

My previous site on this domain was from 2023, and since then I hadn't updated it (my portfolio website said I was 18yrs old till today). The reason: I hated writing JS code or adopting a web framework (it scared me). But I needed a way to keep my website updated without writing a single line of JS - hence forge was born.

The concept of Static Site Generators (SSGs) was quite amusing to me cause they're kind of a compiler that converts one language to another - or in this case, Markdown files to HTML + CSS. I started researching how these work; at first they seemed extremely complex. Looking at the wide variety of choices I had (Hugo, Anna <- Made by my peers in college btw check it out!, Eleventy etc), I decided to just pick one up and configure it to finish my website.

Researching how SSGs work I landed on goldmark, which already did 90% of the work for me - take a markdown file and convert it to HTML. I then wrote a simple script in Go to read content/ and write the goldmark output to dist/ and voila! I had a bare bones SSG ready.

Caveman's SSG

Obviously the site was awful to look at - no metadata, no styles, just plain HTML - but it did let me skip JS and have an updated site. So I decided to make this a full-fledged project. The first thing I finalized was the directory structure every site should follow. Reading through the docs of various SSGs, I found Hugo's the easiest to understand, so I took inspiration from that. I wired up forge to read the directories and recursively recreate the same structure in dist/, replacing a xyz.md file with xyz/index.html holding the rendered HTML.

Giving my site some customizability

Now I had basic HTML files converted straight from MD by goldmark, but no way to inject the custom data I wanted. I already knew the solution: HTML templates. I'd used Pug and EJS before, but never one in Go. After hours of reading docs and looking at examples, I finally wrapped my head around html/template and got it working. Now I had true customizability in both data and styles.

Designing the website

I'm a sucker for dark themes and genuinely feel light mode shouldn't exist (okay, I've seen a few good light ones - not many :P). Picking the colour palette was easy: I yoinked the colours from my previous site and warmed the text up a little to make it feel cozy (though sometimes I feel like I made it look AI generated, idk). For the layout I kept it simple, mimicking a blog design - and, as I do on every site, I added a Pokémon sprite from here somewhere on the page. Look top-left :)

Optimizations

This is the fun part, and it's ongoing - so I'll keep this updated.

(Still cooking: a benchmark to see how forge stacks up against Hugo, and a proper test suite.)