Skip to content

Hugo iterate pages of section

The Valley of Code

Your Web Development Manual

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
  • THE VALLEY OF CODE (+ PRO), your web development manual
  • I wrote 15+ free coding BOOKS, download them here
  • SOLOPRENEUR LAND the missing MBA for wannabe solopreneurs craving a life with more freedom, control, fulfillment and purpose (summer 2024)