GroupBy
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 }}