What is hugo?
Hugo is a static site generator written in go. It is the main program powering this website. Being a static site generator what it does is read a bunch of markdown files and some theme and configuration files as input and produce a fully static website as output. This makes it great for personal websites and especially blogs where you don’t have to deal with user-generated content.
Why hugo?
Previously this website used a dynamic page with a database back-end and even
features in place for user authentication (even though that was never
finished). For quite some time I wanted to add blogging functionality to the
website but didn’t really find the time or energy to work on a fully dynamic
solution for the blog page. As I also make music I wanted to publish that (found
here) and searched for a solution. Initially
I contemplated publishing my music on a third party service like soundcloud or a
fediverse alternative like funkwhale, but by accident I discovered
faircamp – a static site generator for
musicians who want to publish their music. Now since I have my domain already
setup it wasn’t really hard to set that up. And the best thing, since the static
site generator is configurable, all of the content including metadata and
configuration is hosted in git
(using git-lfs
for the audio files themselves).
Now hugo fills the same niche but for blogs and personal websites in general instead of specifically music hosting. And the best thing for users is how easy it is to setup.
Setting up hugo
Now I won’t go over setting up hugo in detail, there are way better resources available to learn about that, but I will go over how I setup my hugo page.
Theme
Something great with good static pages is that they can easily be themed using for example CSS. Hugo can go a step further. The only thing I am writing is the content of the post in markdown and hugo automatically adds all the important site information around like headers, footers and navigation helps. The exact way this is done is controlled by a theme. For starting out I picked a nice pre-made theme from hugos theme page and configured it to my liking. In the future I might look into writing my own theme as it seems to be really simple to get started with that.
Managing content
Because hugo is a static site generator I can also easily add tags to posts without concerning myself with exactly how to link to specific pages and how they have to look. In fact, I never had to write the page for the tags overview (found here). All of this is really good for authors as you setup your system once and after that all you need to do is add content.
Using git with hugo
Git is a popular version control system mainly intended
to be used with source code for applications (like hugo itself). But you’re not
limited to application source code. Git is very good at managing anything that
is text (and with git-lfs
you can even relatively easily manage images, videos
and audio files). Now the basic content format of hugo is markdown which is a
text-based file format so it becomes natural to manage your hugo page with git.
In fact, this page is found in a git repository. The main things to note for
using hugo with git are the following:
- use
git-lfs
for images and other binary content you use - if you use an external theme include it as a git submodule
- add the
public
folder to your.gitignore
Multiple authors and comments
If you want to host a webpage for a small company where blog posts might be written by multiple people you might think hugo comes to its limits. Well, sort-of. For multiple authors it is recommended to have a collaboration platform like git setup for your webpage. In this case it is actually really easy: In the posts themselves add information on who wrote the specific post and hugo will handle the rest. And multiple people working on the same files is handled by git.
As for comments, this is truly a far reach to implement for hugo. I have seen pages using a github field to contribute comments to a page, but I personally don’t think that this is a good solution. If you absolutely need comments you are probably better off using something other than hugo but I would say, giving up comments isn’t that hight of a price to pay for most people who want to host a small personal homepage or blog.
Closing notes
With hugo you have a powerful tool at your disposal for managing a personal webpage and/or blog. And it is all static webpages with minimal JavaScript dependencies only where absolutely necessary (for certain features like searching a webpage). Because of this your website will perform a lot better than other websites