Updating this website

I wrote a blog post not too long ago where I described how I write and publish my posts. I described how I would put together txt files in Emacs, copy them over to my server with ssh and then update the blog’s index. (Although as of late I’m just writing them directly on my server over tramp, saves me from having to copy them over.)

To be honest it was a really nice system. Making new posts was effortless, and serving my content as txt instead of html felt novel and cool.

But, it severely limited me in how I could style the site.

I didn’t want there to be a discrepancy between the txt files and the main website. This meant I had to use the system default monospace font for the entire website, as well as the system default light and dark colour schemes. While it looked okay, I was never totally happy with it.

I was also just really lazy. The thought of having to add proper tags to all my documents did not spark joy.

I had a conversation with a friend a few days ago where we discussed how he could put blog posts on his site. He didn’t like the idea of having plain txt files, and I realised that what I had viewed as tedious could easily be automated with a script.

So I decided to try it myself.

I first experimented with having a custom bash script which parsed my files and generated valid html, but I decided to keep things simple. Red Hat packages the ‘discount’ distribution of Markdown in their repos, which obviously comes with a converter, no need for me to make my own. So now, I have this:

#!/bin/sh
#
# Convert markdown to html and add a header and footer.

if [ -z "$1" ]; then
    echo "Usage: $0 filename.md"
    exit 1
elif [ ! -f "$1" ]; then
    echo "$1 not found"
    exit 1
fi

input_file="$1"
output_file="${input_file%.md}.htm"

markdown "$input_file" > tmp.htm
cat ../common/head.htm tmp.htm ../common/foot.htm > "$output_file"

mv "$input_file" md/
rm tmp.htm

Super simple, right?

So what has changed in terms of workflow? Well, instead of writing posts in pure plain text, I’m now writing them in Markdown. The process is the same, I’m just now adding Atx-style headers, and making sure that special paragraphs such as lists and code blocks are properly formatted. And when I’m done with the post I simply run the above script, do some minor touch ups, and update the index. (Writing this now I realise I could also have the index updated automagically as part of the script 🤔).

All this has allowed me to actually theme the website in a way that I now like. I’m using Fira Code across the entire site, the type is larger, content is centered, there’s a navigation bar, and I’m no longer using those default colours. While I have lost some of the original minimalism which I believe made this site great, I also believe these changes have been for the better. It’s still not more complex than it needs to be, the workflow isn’t too different, and I still have the old stuff squirreled away in case I have a change of heart in the future.

I was toying with the idea of going through my older posts and updating them to this new format as well, but I think it would be nice to keep them as they are, just as a reminder of how things used to be. I’ve gone ahead and updated everything from the past year, but anything from before that is still how it used to be.

What’s left is to make this place a teeny tiny bit more mobile friendly, but it’s low on the list.