You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.7 KiB
Markdown

---
draft: false
title: "Filtering Hugo pages by Type"
aliases: ["Filtering Hugo pages by Type"]
series: ["blogging-with-quartz"]
series_order: 4
date: "2023-04-08"
author: "Nick Dumas"
cover: ""
keywords: ["", ""]
summary: "More complex Hugo sites sometimes require creating markdown files you don't want displayed in specific listings."
showFullContent: false
tags:
- hugo
- quartz
- webdev
---
## 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](/series/blogging-with-quartz).
Being able to embed some graphics and write short summaries of each series would be nice, so I've been experimenting with adding `_index.md` and `index.md` 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
``` {title="recent.html"}
{{$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](https://gohugo.io/content-management/types/) assigned to it. This ends up being the simplest option for filtering for now.
``` {title="recentNotes.html"}
{{$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.