Hugo is a framework for building websites. It is particularly adept with blogging, and sites that are primarily static, but has many great use cases. It claims to be the fastest, and it is very fast, but this is not about benchmarking.
I will be using Dreamhost as my shared hosting provider, because I have been using them since 2006, they have never done me wrong, and they seem to treat humans and robots well.
This post won't cover everything starting from scratch, as I already have a site running, and just need to upgrade it, but I may expand it over time with additional setup details. Many parts of the upgrade process are the same as the ones used to setup initially.
- Go to https://github.com/gohugoio/hugo/releases
- Within the latest (currently
0.101.0) release section, scroll down to
Assets, and find the link to the
debpackage. In my case it is named:
- Right click the link, and copy the link address, you will paste it in the next step after
wget. In my case the URL is
- Open a text editor and start building the commands you will later run.
# ssh into server... # Make a 'faux-root' directory. > FAUXROOT=~/root > mkdir -p $FAUXROOT # Make a directory to hold the `.deb` packages you download. > mkdir -p debs > cd debs # Download Hugo. NOTE: Replace this link with the link you copied (probably a newer version of Hugo). > wget https://github.com/gohugoio/hugo/releases/download/v0.101.0/hugo_extended_0.101.0_Linux-64bit.deb # Download any other .deb packages you may need into this same directory. # Then install them all. > for d in *.deb; do echo "Installing $d"; dpkg -x $d $FAUXROOT; done
Now you have Hugo installed! Create a file
#!/usr/bin/env bash set -x # ENV setup FAUXROOT=~/root # Website Info SITE_NAME=railsbling SITE_TLD=com SITE_DOMAIN="$SITE_NAME.$SITE_TLD" SITE_URL="http://www.$SITE_DOMAIN" # What is the theme? THEME_NAME=toha # Check that Hugo is installed and available at the expected path. $FAUXROOT/usr/local/bin/hugo version # I have my git repo replicated on my server, so this is a path to a repo (not a clone of a repo, an actual repo). # You could change this to any kind of git-cloneable address. # It doesn't need to be an actual repo path, just needs to be a cloneable thing. SITE_REPO=$HOME/$SITE_NAME.git # This temporary directory is used by the build process. # We clone the (local) repo, and remote submodule theme everytime we update. SITE_TMP=$HOME/tmp/$SITE_NAME # Where the final, built, site will land, to be served on the internet. SITE_WWW=$HOME/$SITE_DOMAIN # Clone into the temporary directories. rm -rf "$SITE_TMP" git clone "$SITE_REPO" "$SITE_TMP" --recurse-submodules # Then build $FAUXROOT/usr/local/bin/hugo --theme="$THEME_NAME" -s "$SITE_TMP" -d "$SITE_WWW" -b "$SITE_URL"
You can now call this script from your git
post-receive hook (
$SITE_REPO/.git/hooks/post-receive) if you want. When I do that I get a strange error from git that I haven't figured out, so I still have to run it manually.
remote: Start building sites … remote: hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended linux/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio remote: ERROR 2022/06/29 18:18:53 Failed to read Git log: fatal: not a git repository: '.' remote: Error: Error building site: logged 1 error(s) remote: Total in 7075 ms
Anyways, the manual result works, and is not going to win any races... but also, it is a single command now!
Start building sites … hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended linux/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio | EN -------------------+------ Pages | 341 Paginator pages | 33 Non-page files | 0 Static files | 397 Processed images | 40 Aliases | 124 Sitemaps | 1 Cleaned | 0 Total in 7536 ms