Books | Mailing List (marc.info) | Twitter | Github | StackExchange | LinkedIn | About Me

Installing Hugo and publishing Hugo web-pages on OpenBSD server

Hi there,

This is my first blog post on this website, where I have written about the installation of Hugo—a static site generator and then hosting static web pages on OpenBSD server.

Installation - Hugo

I have tested and deployed Hugo on OpenBSD 6.3-stable. And, Hugo is not available in the ports on OpenBSD 6.3, therefore, I have decided to install it from source.


Below are the steps to install Hugo from the source on OpenBSD 6.3:

go get github.com/magefile/mage

cd ${GOPATH:-$HOME/go}/src/github.com/magefile/mage
go run bootstrap.go

Now, execute the following command to copy the mage binary to /usr/bin/ directory:

doas cp $HOME/go/bin/mage /usr/bin/

After that, download Hugo from git:

go get -d github.com/gohugoio/hugo

cd ${GOPATH:-$HOME/go}/src/github.com/gohugoio/hugo
mage vendor
mage install

Now, execute the following command to copy the Hugo binary to /usr/bin/ directory:

doas cp $HOME/go/bin/hugo /usr/bin/

Website generation - Hugo

[xxx@localhost ~]$ hugo new site ~/example-site
Congratulations! Your new Hugo site is created in /home/feddy/example-site.

Just a few more steps and you're ready to go:

1. Download a theme into the same-named folder.
   Choose a theme from https://themes.gohugo.io/, or
   create your own with the "hugo new theme " command.
2. Perhaps you want to add some content. You can add single files
   with "hugo new /.".
3. Start the built-in live server via "hugo server".

Visit https://gohugo.io/ for quickstart guide and full documentation.
[xxx@localhost ~]$
[xxx@localhost ~]$ cd example-site/
[xxx@localhost example-site]$ git clone https://github.com/halogenica/beautifulhugo.git themes/beautifulhugo
Cloning into 'themes/beautifulhugo'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 1786 (delta 4), reused 8 (delta 3), pack-reused 1768
Receiving objects: 100% (1786/1786), 2.45 MiB | 288.00 KiB/s, done.
Resolving deltas: 100% (1053/1053), done.
[xxx@localhost example-site]$

Now, edit the config.toml file and add line theme = "beautifulhugo" and start hugo server:

hugo server -D

or you can also use hugo "-t" option from the command line, like,

hugo server -t beautifulhugo

And, then open the link, in my case it is http://localhost:1313/

Now, add the posts using:

hugo new posts/my-first-post.md

And, I don't want to be distracted from the goal of this blog post, so, for the rest of the documentation, you guys can also visit Hugo website for docs.

Deployment—Sample website

I have been searching a lot on how to deploy the static website after creating from Hugo static site generator. But I have found only git and git-hook script for deployment. And, in my opinion, I think the following is an easy and simple method:

After creation of posts, make sure that "draft = true" has been removed from the posts that you guys are going to publish.

Share on Facebook | Share on Twitter | Share on LinkedIn