A mainly OpenBSD focused collection of how to's.

Hugo on OpenBSD to run your blog

Posted on: 13 Jan 2024

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 7.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 themes/ananke  
    echo 'theme = "ananke"' >> config.toml  
    hugo new posts/  
    vi contents/posts/

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/*  
    $ hugo  
    $ doas cp -r public/. /var/www/htdocs/