Hugo iterate pages of section
New Course Coming Soon:
Get Really Good at Git
I had the need to iterate over the pages of a specific section in Hugo, which means markdown files put inside a folder under content
, like content/mysection
.
Here’s the code to do that:
{{ range (where .Site.Pages "Section" "mysection") }}
{{ range .Pages }}
{{ .RelPermalink }} - {{ .Title }}
{{ end }}
{{ end }}
→ Get my Go Handbook
Here is how can I help you:
- COURSES where I teach everything I know
- CODING BOOTCAMP cohort course - next edition in 2025
- BOOKS 16 coding ebooks you can download for free on JS Python C PHP and lots more
- Follow me on X