On building websites with GoHugo

I regularly come across tweets asking something like “what framework or tools should I use to build my own blog site?". I usually respond by recommending GoHugo, and given the limited amount of characters in a tweet, I usually leave it at that. In this blog post, I want to share a little more background on why I like GoHugo so much.

Let’s start with a little background info I’ve shared before. GoHugo is a static site generator: all dynamic content on the website is resolved on build time, and a set of static files and resources is deployed to the website servers. Simply put: all the work (like calculating which content should be in the requested page) is no longer performed when the page is requested, but during a build process. The results of that build process can be deployed to your server as static (unchanging) files - hence the term Static Site Generator.

Content is just content

In a regular CMS, the content of a page also determines how that page looks. A WYSIWYG editor is usually available, but access to (part of) the HTML code of that page is available as well because page content is stored as HTML.

GoHugo is different: all content is stored as Markdown files. Markdown files can only contain a specific markup, allowing you to focus on writing content instead of how that content looks. GoHugo adds a little extra by allowing you to add shortcodes to Markdown files: simple snippets that GoHugo will render using a predefined template. This enables you to work on your content without worrying about how it looks. Very nice if you’re a solo blogger getting into the zone, and essential if content editing and site layout are separate tasks performed by different people in your organization.

Theme development is fun

I’ve personally never had as much fun creating a theme for my blog as with GoHugo. Working with the built-in live reload functionality allows viewing changes happen in real time in a browser window. GoHugo makes creating sites even more fun by playing nice with modern web development techniques like TypeScript and SASS. There’s no need to worry about weird user styles interfering with your CSS, complex cross-file dependencies or other hassle: it’s just you, a code editor and a browser.

Getting started is easy

Starting with GoHugo is super easy: after you’ve downloaded the executable you can run a command to tell it to “build” a certain directory. GoHugo will then process everything in that directory and generate your html files in a separate directory. The documentation is good too, and there’s example sites that you can download to get a hang of how everything works.

Getting people up to speed with your site is easy as well: they just have to install the GoHugo executable and retrieve your site source files from Git, and they’re good to go!

As superpowered as you want

The above might sound as if GoHugo is mainly suited for small blogs and organizations, but not so much for bigger organizations. That’s not right. GoHugo allows you to scale up from a basic blog to a crosslinked multi-language multi-domain website with hundreds of pages that all look and behave different in a breeze! From optimizing images to generating sitemaps, GoHugo’s got it all.

What about downsides?

There’s some minor things that aren’t perfect about GoHugo. For starters, the Go syntax used for shortcodes and other specific functions has some weird quirks and magic behavior. Also, TypeScript support isn’t great: not all syntax is supported. Besides that, some configuration files have to be TOML files instead of JSON (i18n files for example). Static theme files and static content files may overwrite each other because they end up in the same directory after a build. There’s no way to use a shortcode inside another shortcode - you’ll have to use partials.

Are these deal breakers? Not for me, and not for Uptrends. We’ve recently rebuilt the Uptrends website using GoHugo and we’re very happy with it. If you’re looking for a new framework to build your site on, you should try it too some time.