Debian Codegraph @

docs/content/en/methods/pages/ByParam.md

raw
1 ---
2 title: ByParam
3 description: Returns the given page collection sorted by the given parameter in ascending order.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.Pages
9 signatures: [PAGES.ByParam PARAM]
10 ---
11
12 If the given parameter is not present in front matter, Hugo will use the matching parameter in your project configuration if present.
13
14 ```go-html-template
15 {{ range .Pages.ByParam "author" }}
16 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
17 {{ end }}
18 ```
19
20 To sort in descending order:
21
22 ```go-html-template
23 {{ range (.Pages.ByParam "author").Reverse }}
24 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
25 {{ end }}
26 ```
27
28 If the targeted parameter is nested, access the field using dot notation:
29
30 ```go-html-template
31 {{ range .Pages.ByParam "author.last_name" }}
32 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
33 {{ end }}
34 ```