GroupByParam
Returns the given page collection grouped by the given parameter in ascending order.
- Syntax
- PAGES.GroupByParam PARAM [SORT]
- Returns
- page.PagesGroup
For the optional sort order, specify either asc for ascending order, or desc for descending order.
Use the GroupByParam method to group by a custom field. To group by a reserved field, pass the name of the corresponding Page method to the GroupBy method.
{{ range .Pages.GroupByParam "color" }}
<p>{{ .Key | title }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}To sort the groups in descending order:
{{ range .Pages.GroupByParam "color" "desc" }}
<p>{{ .Key | title }}</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