Debian Codegraph @

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

raw
1 ---
2 title: ByPublishDate
3 description: Returns the given page collection sorted by publish date in ascending order.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.Pages
9 signatures: [PAGES.ByPublishDate]
10 ---
11
12 When sorting by publish date, the value is determined by your [project configuration], defaulting to the `publishDate` field in front matter.
13
14 [project configuration]: /configuration/front-matter/#dates
15
16 ```go-html-template
17 {{ range .Pages.ByPublishDate }}
18 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
19 {{ end }}
20 ```
21
22 To sort in descending order:
23
24 ```go-html-template
25 {{ range .Pages.ByPublishDate.Reverse }}
26 <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
27 {{ end }}
28 ```