Just some quick blog post updates

This post is both something I should have written years ago and an update post all in one!

A few years ago I moved my site from Drupal to Hugo. I did it for a few reasons but most of them revolve around upkeep. Back when I did full time Drupal development for my day job the last thing I wanted to do after work was update a Drupal site. These days you just can’t let a dynamic site sit there, they need constant updates to stay secure so something had to give. Nothing against Drupal, it was just too much for me to maintain for a very simple blog. I messed around with a few static site generators until I landed on Hugo. It did what I wanted, didn’t make too many assumptions and ultimately was fast! As a great side benefit I no longer have to run complex servers so it’s a little more environmentally friendly.

Remember when I said the static site doesn’t require upkeep. Well, that’s kind of true. What I published didn’t require any changes and could stay up forever. It’s just HTML and CSS, that’s the beauty of it. The part I did have to maintain or at least catch-up was Hugo, my post processing steps and deployment.

Hugo is fairly stable in it’s feature set and all you have to do is drop in the latest version of the executable and you are good to go. I did run into one issue. The table of contents. For some reason they changed it that the table of contents value used to be empty if it wasn’t used to now having 33 characters in it and failing a simple IF. Thanks to jacksonchen666 I found an answer. Simply check if there are more than 33 characters in .TableOfContents.

{{- /* check to see if not empty */ -}}
{{ if ge (len (.TableOfContents)) 33 -}}
<details><summary>table of contents</summary>
    {{ .TableOfContents }}
</details>
{{- else -}}
<hr>
{{- end -}}

As for the deployment, things became easier for once. I use AWS S3 and Cloudfront for my hosting. I can host my entire site for less than $1 a month. I used to use some NodeJS based deployment script and it was full featured but always a pain to setup. I noticed that somewhere in my multi-year hiatus that Hugo added deploy functionality. All I had to do was setup aws-cli and add a few config items. One less thing to have to worry about.

Oh, it turns out AWS Cloudfront added a few extra things while I wasn’t looking as well! Cloudfront can now add HTTP headers as well as do variable compression on your HTML. This allowed me to remove the custom AWS Lambda that I wrote to do those two functions. Easier, more stable and something I can set and forget. This is feeling like a theme.

I hope that now I’ve got my blog authoring and deployment up and running I can write more. We’ll see.