2023-08-02

Blogging With Hugo and Org-mode

This blog is generated with Hugo. The source is currently here.

I set it up a bit differently than many tutorials, so I thought I would describe what I did and why. I did not use a theme; I just wrote a few layouts and a short CSS file for a brutalist design. I wanted to be able to understand and control my design rather than try to figure out how to get what I wanted out of an existing theme.

I like the expressivity and clarity of Org mode syntax rather than Markdown. Thankfully, Hugo can read Org files good enough for me. go-org, the library Hugo uses to parse Org files, is intended "to support a reasonable subset of Org mode". There is also ox-hugo, an Org exporter to Hugo Markdown, but I have not tried it yet.

(Update 2024-10-26: I've been using Markdown also. Org mode is nice, but Markdown is more common, and since I've been using Markdown in other places where org mode can't be used, I find it easier to stick with one syntax. Hugo handles both fine, so there's no need to convert files.)

I'm not sure how much I will blog, but probably not a lot. My main motivation for starting a blog is to write down things I have learned. Hopefully some of what I write will be helpful to others, but I also want something for myself to refresh my memory later. I have learned a lot from people that write down things they have learned, whether they are experts or not. I want to do my part to keep that tradition strong.

Of course, it's also possible there will be long periods of silence occasionally interrupted by posts about my intentions to start blogging again. ;)

(Update 2023-11-24: I switched to using srht.site to host this. Source here, including the .build.yml file to build and deploy the site using builds.sr.ht. Below is how I was hosting it at first, which I'll leave up in case it's useful to someone. I decided to save the money I was spending on a VPS since I wasn't using it for much.)

I am using a Linode VPS (virtual private server) to host the website (among other things). I have the source in a git repository with this post-receive hook to deploy the site after a successful git push:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

GIT_REPO=/var/lib/git/markpenner.space.git
WORK_DIR=/tmp/work_dir
TARGET=/var/www/html
BACKUP=/tmp/backup_html

echo "Post receive hook starting"
set -e

rm -rf $WORK_DIR $BACKUP

echo "Making temporary directories."
mkdir -p $WORK_DIR $BACKUP

rsync -aqz $TARGET/ $BACKUP
trap "echo 'A problem occurred.  Reverting to backup.'; rsync -aqz --del $BACKUP/ $TARGET; rm -rf $WORK_DIR $BACKUP" EXIT

echo "Pulling into temporary directory."
git clone $GIT_REPO $WORK_DIR

echo "Removing existing site."
rm -rf $TARGET/*

echo "building new site"
hugo -s $WORK_DIR -d $TARGET

echo "Removing temporary directories."
rm -rf $WORK_DIR $BACKUP
trap - EXIT

Tags: Blog Website