Hugo SSG

How to Create a Recommended Reading Function

How to display a list of data items based on matching taxonomy terms. The technique is similar to a “Related Posts” function, but here we create a collection of data records instead of content pages.

View »

How to Use Range, Where and Sort in Hugo

Various combinations of using range, where, first, sort, uniq, union, intersect, etc. in Hugo and Go Templates. Many are based on the Hugo Docs, but collected here in one place for easier access. Syntax Range range COLLECTION Where where COLLECTION KEY [OPERATOR] MATCH Sort Sorts slices, maps, and page collections. collections.Sort COLLECTION [KEY] [ORDER] Intersect Returns the common elements of two arrays or slices, in the same order as the first array.

View »

Am I Viewing Localhost?

When working locally, it’s easy to get confused while switching quickly between development and production views of your site. All that’s really needed is a glance at the URL, but errors slip in when you think you’re looking at the development version, and don’t notice that you’re not. In Hugo, one quick way to avoid the mixup is to add alternate css for the builtin local development server. This is easy to do because Hugo sets the builtin variable .

View »

Default Taxonomy Template in Hugo

How to create a default taxonomy template in Hugo.

View »

Using Scratch to Increment a Counter in a Range

Scratch was originally added to Hugo to get around a limitation of Go templates. Due to advances in Go Templates, Scratch is no longer needed in most situations, but it still works.

View »

HTML5 Charts in Hugo

Thanks to the good work of Shen Yu and a global community of hackers, it is now easy to add fancy charts to Hugo Websites. Here are my first experiments.

View »

Directory Listings in Hugo

How to create a list of files from a directory in Hugo.

View »

How to Generate a Random Value in Hugo

How to create a list of files from a directory in Hugo.

View »

List Related Content

How to create a list of files from a directory in Hugo.

View »

Working With Taxonomy Templates in Hugo

Here’s a good overview: https://discourse.gohugo.io/t/handling-taxonomies-like-a-boss-update/7719 It includes info on how to: Create custom taxonomies Add custom metadata to taxonomies Create a list template for taxonomy terms using the custom metadata added to the taxonomy Handle terms without a corresponding _index.md file and define default values in your templates Create a taxonomy templates for listing all terms within a specific taxonomy Speed up the creation of unique terms pages using Hugo Archetypes More information https://discourse.

View »