GroupBy
Returns the given page collection grouped by the given field in ascending order.
- Syntax
- PAGES.GroupBy FIELD [SORT]
- Returns
- page.PagesGroup
For the optional sort order, specify either asc for ascending order, or desc for descending order.
{{ range .Pages.GroupBy "Section" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}To sort the groups in descending order:
{{ range .Pages.GroupBy "Section" "desc" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}Last updated:
October 27, 2026
:
content: Flatten and rename _common snippets (1da4dad14)
Improve this page