Getting started with Hugo

I am finally getting ready to set up my new personal website! Though a Drupal fan, I have decided to use Hugo static site generator for this project. Indeed, Hugo reminds me of the Good Ol’ Days of using the venerable WML (Website Meta Language) for website generation back in late 1990s, except that Hugo is modern and extremely speedy! It is orders of magnitude faster than anything out there, written in the cool new Go programming language.

So, henceforth begins my adventure of buildling websites with Hugo!

Note: the following content, originally written in September 2014, is still a draft and is subject to change.

Installing and Upgrading Hugo from source

Installation

mkdir
export GOPATH=$HOME/go # or something else
go get -v github.com/spf13/hugo
# After "go get", I actually find a compiled "hugo" binary inside $GOPATH/bin.
# So, no "go build" is necessary?
go build -v github.com/spf13/hugo
# For "go clean", the -i flag is somewhat dangerous:
# While it would remove the "*.a" found in my local $GOPATH/pkg/linux_amd64/ directory,
# which is what I wanted,
# it would also attempts to delete system-wide /usr/lib/go/pkg/linux_amd64/*/*.a, which is NOT
# what I wanted. Thank goodness that I was not using sudo ...
#
go clean -i -r -v github.com/spf13/hugo

Upgrade

Supposedly, I could run:

go get -v -u github.com/spf13/hugo

But I have not fully confirmed that it indeeds work that way, and I don’t have time to investigate deeper today.

Generate a site skeleton!

$ hugo new site /work/web/anthonyfok.org
$ cd /work/web/anthonyfok.org
$ vim config.toml # And fill it out the way we want.
# TODO: What to do with m17n sites?

Troubleshooting: Why can’t I see anything HTML files being generated?

Nothing gets generated when we haven’t installed any themes! So, make sure we follow “Step 4. Install some themes” in the official documentation.

Make sure you have included the -D flag, as in:

hugo -w -D -t redlounge

or, with long form flags:

hugo --watch --buildDrafts=true --theme redlounge

because new pages are “drafts” and not built by default.

Sidenote: We used to have 2 themes only, but now we have 12 in August 2014!

Things to add to official documentation

What dialect of Markdown?

Answer: Almost the same as GFM (GitHub Flavored Markdown), with the exception of Syntax highlighting in code blocks (since Linguist isn’t used?) with syntax highlighting provided by either server-side (Pygments) or client-side (JavaScript) solutions.

Deploying to a local Apache web server on Debian/Ubuntu

Add something like

127.0.2.1 local.anthonyfok.org

to /etc/hosts.

Then, create /etc/apache2/sites-available/local.anthonyfok.org.conf with the following content: