Jack Baker | Developer

Creating a Static Blog Generation Tool

February 12, 2025

In updating this site here I've decided to keep a journal (inspired partly by hikware's blog), even if it seems inconsequential. I didn't want to just load in some huge wordpress monster, and given my need to espouse static HTML over everything, I wanted to make one myself. In addition, I recently realized that I can't remember the last time I did some programming solely for myself, and not for work. Granted, this is not a requirement for being a "Good Programmer", just like we don't ask doctors to perform freelance surgery on the weekends, but I've been missing some recreational programming lately.

Please do not attempt to use the following as any sort of instructional guide to programming. It won't be very useful even if you can keep track of what I'm talking about.

I also didn't want to be manually writing html every time I made a post, so I started thinking about how to format the source posts. I initially thought about JSON, but also decided against that, since that's only one step away from writing html, and writing everything one level indented or as a single/multiline string just felt bad and not natural. I liked the simplicity of a collection of text files stored on a disk somewhere, each representing a single post. (also it's my file format I can do what I want.) That way I could update it from wherever I wanted, from anywhere you can edit a text file. I'm writing this from Notepad++ because apparently the uglier software looks, the more I like it (see also foobar2000, SequioaView, and the ever-steady WinRAR.)

I've been working with quite a bit of Golang recently, so naturally started from there. I settled on the structure of the post file thusly: first line - Post Title, second line - post date, rest of the file being the text of the post, the same way that you would write a diary or journal entry (even now, when it's been a thing for almost my entire life, the word "blog" stil feels weird in the mouth.) Later on in the process (i.e. moments before writing this entry) I added an empty line between the date and the body text in the off chance that I decide to add something like a tagging system, or some other extension. For now it serves as a nice little break in the text editor after the title.

The general flow works like this: in sequence, read in each file, parsing out the title and effective date. Line by line, through the body of the text, translate the formatting markings into html formatting. Once each file is read, wrap that block of p tags into all the various HTML accoutrement that's needed for a "more" valid page. This is the side navigational panel and header bar, delivered as embedded iframes. With the overall list of posts, sort them by reverse chronological order and write out a list of posts as an archive. Anything more in-depth, like a "posts by month" or other grouping would likely only serve to highlight the infrequency of updates, so hurray for skipping features.

I chose a markdown-like syntax because it gives me all the tools I truly need for emphasis, and none that I don't. Images and links get formatted into html embeds with some simple regexes and capture groups. If I really want to, I can type out some emoji which will be passed through and shown to you in full color glory. The current way this blog is generated is by simply running the program I created, pointing it to a folder of text files, and then copying the output into a static HTML hosting site (in this case, the repository for my github page.) I could automate this step by running the generator as a Lambda function or as some step on a GitHub Action workflow which automatically creates a cross-repo pull request, etc, but that's a problem for future me, if he even decides to pick it up. The current code lives in the bloggen repository.