Using Hugo to run your blog on OpenBSD
Hugo is one of the most popular open-source static site generators. It’s written in Go (aka Golang) and developed by bep, spf13 and friends. I find it to be simple and easy to use but it also has some great themes to choose from.
Assumes httpd being used on OpenBSD, tested with 6.4
Install hugo and verify your install
doas pkg_add hugo hugo version
Create your new blog working folder
hugo new site blog cd blog git init git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke echo 'theme = "ananke"' >> config.toml hugo new posts/my-first-post.md vi contents/posts/my-first-post.md
Note that your posts are contained in a folder called contents and the name of the posts folder can vary with each theme, some use posts some use post others might use something else like docs so read the theme documentation. Another gotcha is to check the
draft: true at the top of the .md file and change it to
draft: false when you want that post included in the build. I found myself buidling the site and then discovering that there were no posts included, this or the posts/post/docs could be the problem.
Deploying your site
Run hugo without any arguments and it’ll build your site into public. I wrote a little script you can use to deploy it but obviously you can use the commands separately to get the hang of it and build your site manually.
rm -r public doas rm -r /var/www/htdocs/blog.example.com/* hugo doas cp -r public/. /var/www/htdocs/blog.example.com/