ByWeight
Returns the given page collection sorted by weight in ascending order.
Syntax
PAGES.ByWeight
Returns
page.Pages
Assign a weight to a page using the weight field in front matter. The weight must be a non-zero integer. Lighter items float to the top, while heavier items sink to the bottom. Unweighted or zero-weighted pages are placed at the end of the collection.
{{ range .Pages.ByWeight }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}To sort in descending order:
{{ range .Pages.ByWeight.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}Last updated:
April 10, 2025
:
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65' (283e97783)
Improve this page