Skip to main content
  1. Posts/

Filtering Hugo pages by Type

·205 words·1 min·
Nick Dumas
Table of Contents
blogging-with-quartz - This article is part of a series.
Part 4: This Article

What am I Doing?

As part of my effort to beautify my series features, I’m trying to set up a landing page where I can add arbitrary markdown content. You can see an example of one of these pages here.

Being able to embed some graphics and write short summaries of each series would be nice, so I’ve been experimenting with adding and files at various places.

Why doesn’t it work?

The problem here is that the query in my recent.html partial was fetching pages were a little too vague and caught these

{{$notes := .Site.RegularPages.ByLastmod.Reverse}}

What are the options?

Hugo has a bunch of different ways of grabbing groups of Pages. There’s page bundles, taxonomies, and more.

I picked X

Each page has a Content Type assigned to it. This ends up being the simplest option for filtering for now.

  {{$notes := where site.RegularPages "Type" "notes"}}

I think the actual smart thing I did was factor the “notes” query into a dedicated partial: recentNotes.html.

In a perfect world I’d parameterize this partial, but I’m not really sure that’s even possible in Hugo. Partials explicitly accept up to one argument, no more.

Maybe this is what shortcodes are for.

blogging-with-quartz - This article is part of a series.
Part 4: This Article


Adding Series and Navigation links to Hugo page
·699 words·4 mins
Extending Quartz’s single.html to link between posts.
Gardening with Quartz
·1660 words·8 mins
When you want a container built right, you have to do it yourself.
Automating Caddy on my DigitalOcean Droplet
·712 words·4 mins
Automation ambitions fall flat