Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'

This commit is contained in:
Bjørn Erik Pedersen
2023-12-04 15:24:01 +01:00
810 changed files with 24147 additions and 7766 deletions

View File

@@ -0,0 +1,31 @@
---
title: ByDate
description: Returns the given page collection sorted by date in ascending order.
categories: []
keywords: []
action:
related:
- methods/pages/ByExpiryDate
- methods/pages/ByLastMod
- methods/pages/ByPublishDate
returnType: page.Pages
signatures: [PAGES.ByDate]
---
When sorting by date, the value is determined by your [site configuration], defaulting to the `date` field in front matter.
[site configuration]: /getting-started/configuration/#configure-dates
```go-html-template
{{ range .Pages.ByDate }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByDate.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,31 @@
---
title: ByExpiryDate
description: Returns the given page collection sorted by expiration date in ascending order.
categories: []
keywords: []
action:
related:
- methods/pages/ByDate
- methods/pages/ByLastMod
- methods/pages/ByPublishDate
returnType: page.Pages
signatures: [PAGES.ByExpiryDate]
---
When sorting by expiration date, the value is determined by your [site configuration], defaulting to the `expiryDate` field in front matter.
[site configuration]: /getting-started/configuration/#configure-dates
```go-html-template
{{ range .Pages.ByExpiryDate }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByExpiryDate.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,24 @@
---
title: ByLanguage
description: Returns the given page collection sorted by language in ascending order.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.ByLanguage]
---
```go-html-template
{{ range .Site.AllPages.ByLanguage }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Site.AllPages.ByLanguage.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,31 @@
---
title: ByLastmod
description: Returns the given page collection sorted by last modification date in ascending order.
categories: []
keywords: []
action:
related:
- methods/pages/ByDate
- methods/pages/ByExpiryDate
- methods/pages/ByPublishDate
returnType: page.Pages
signatures: [PAGES.ByLastmod]
---
When sorting by last modification date, the value is determined by your [site configuration], defaulting to the `lastmod` field in front matter.
[site configuration]: /getting-started/configuration/#configure-dates
```go-html-template
{{ range .Pages.ByLastmod }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByLastmod.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,24 @@
---
title: ByLength
description: Returns the given page collection sorted by content length in ascending order.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.ByLength]
---
```go-html-template
{{ range .Pages.ByLength }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByLength.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,26 @@
---
title: ByLinkTitle
description: Returns the given page collection sorted by link title in ascending order, falling back to title if link title is not defined.
categories: []
keywords: []
action:
related:
- methods/pages/ByTitle
- methods/pages/ByParam
returnType: page.Pages
signatures: [PAGES.ByLinkTitle]
---
```go-html-template
{{ range .Pages.ByLinkTitle }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByLinkTitle.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,36 @@
---
title: ByParam
description: Returns the given page collection sorted by the given parameter in ascending order.
categories: []
keywords: []
action:
related:
- methods/pages/ByTitle
- methods/pages/ByLinkTitle
returnType: page.Pages
signatures: [PAGES.ByParam PARAM]
---
If the given parameter is not present in front matter, Hugo will use the matching parameter in your site configuration if present.
```go-html-template
{{ range .Pages.ByParam "author" }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range (.Pages.ByParam "author").Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
If the targeted parameter is nested, access the field using dot notation:
```go-html-template
{{ range .Pages.ByParam "author.last_name" }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,31 @@
---
title: ByPublishDate
description: Returns the given page collection sorted by publish date in ascending order.
categories: []
keywords: []
action:
related:
- methods/pages/ByDate
- methods/pages/ByExpiryDate
- methods/pages/ByLastMod
returnType: page.Pages
signatures: [PAGES.ByPublishDate]
---
When sorting by publish date, the value is determined by your [site configuration], defaulting to the `publishDate` field in front matter.
[site configuration]: /getting-started/configuration/#configure-dates
```go-html-template
{{ range .Pages.ByPublishDate }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByPublishDate.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,26 @@
---
title: ByTitle
description: Returns the given page collection sorted by title in ascending order.
categories: []
keywords: []
action:
related:
- methods/pages/ByLinkTitle
- methods/pages/ByParam
returnType: page.Pages
signatures: [PAGES.ByTitle]
---
```go-html-template
{{ range .Pages.ByTitle }}
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByTitle.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,28 @@
---
title: ByWeight
description: Returns the given page collection sorted by weight in ascending order.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.ByWeight]
---
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.
[weight]: /getting-started/glossary/#weight
```go-html-template
{{ range .Pages.ByWeight }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```
To sort in descending order:
```go-html-template
{{ range .Pages.ByWeight.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,36 @@
---
title: GroupBy
description: Returns the given page collection grouped by the given field in ascending order.
categories: []
keywords: []
action:
related: []
returnType: page.PagesGroup
signatures: ['PAGES.GroupBy FIELD [SORT]']
---
{{% include "methods/pages/_common/group-sort-order.md" %}}
```go-html-template
{{ 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:
```go-html-template
{{ range .Pages.GroupBy "Section" "desc" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,68 @@
---
title: GroupByDate
description: Returns the given page collection grouped by date in descending order.
categories: []
keywords: []
action:
related:
- methods/pages/GroupByExpiryDate
- methods/pages/GroupByLastMod
- methods/pages/GroupByParamDate
- methods/pages/GroupByPublishDate
returnType: page.PagesGroup
signatures: ['PAGES.GroupByDate LAYOUT [SORT]']
---
When grouping by date, the value is determined by your [site configuration], defaulting to the `date` field in front matter.
The [layout string] has the same format as the layout string for the [`time.Format`] function. The resulting group key is [localized] for language and region.
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[localized]: /getting-started/glossary/#localization
[site configuration]: /getting-started/configuration/#configure-dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
To group content by year and month:
```go-html-template
{{ range .Pages.GroupByDate "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
To sort the groups in ascending order:
```go-html-template
{{ range .Pages.GroupByDate "January 2006" "asc" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
The pages within each group will also be sorted by date, either ascending or descending depending on the grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
```go-html-template
{{ range .Pages.GroupByDate "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages.ByTitle }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
```
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}

View File

@@ -0,0 +1,68 @@
---
title: GroupByExpiryDate
description: Returns the given page collection grouped by expiration date in descending order.
categories: []
keywords: []
action:
related:
- methods/pages/GroupByDate
- methods/pages/GroupByLastMod
- methods/pages/GroupByParamDate
- methods/pages/GroupByPublishDate
returnType: page.PagesGroup
signatures: ['PAGES.GroupByExpiryDate LAYOUT [SORT]']
---
When grouping by expiration date, the value is determined by your [site configuration], defaulting to the `expiryDate` field in front matter.
The [layout string] has the same format as the layout string for the [`time.Format`] function. The resulting group key is [localized] for language and region.
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[localized]: /getting-started/glossary/#localization
[site configuration]: /getting-started/configuration/#configure-dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
To group content by year and month:
```go-html-template
{{ range .Pages.GroupByExpiryDate "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
To sort the groups in ascending order:
```go-html-template
{{ range .Pages.GroupByExpiryDate "January 2006" "asc" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
The pages within each group will also be sorted by expiration date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
```go-html-template
{{ range .Pages.GroupByExpiryDate "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages.ByTitle }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
```
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}

View File

@@ -0,0 +1,68 @@
---
title: GroupByLastmod
description: Returns the given page collection grouped by last modification date in descending order.
categories: []
keywords: []
action:
related:
- methods/pages/GroupByDate
- methods/pages/GroupByExpiryDate
- methods/pages/GroupByParamDate
- methods/pages/GroupByPublishDate
returnType: page.PagesGroup
signatures: ['PAGES.GroupByLastmod LAYOUT [SORT]']
---
When grouping by last modification date, the value is determined by your [site configuration], defaulting to the `lastmod` field in front matter.
The [layout string] has the same format as the layout string for the [`time.Format`] function. The resulting group key is [localized] for language and region.
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[localized]: /getting-started/glossary/#localization
[site configuration]: /getting-started/configuration/#configure-dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
To group content by year and month:
```go-html-template
{{ range .Pages.GroupByLastmod "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
To sort the groups in ascending order:
```go-html-template
{{ range .Pages.GroupByLastmod "January 2006" "asc" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
The pages within each group will also be sorted by last modification date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
```go-html-template
{{ range .Pages.GroupByLastmod "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages.ByTitle }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
```
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}

View File

@@ -0,0 +1,36 @@
---
title: GroupByParam
description: Returns the given page collection grouped by the given parameter in ascending order.
categories: []
keywords: []
action:
related: []
returnType: page.PagesGroup
signatures: ['PAGES.GroupByParam PARAM [SORT]']
---
{{% include "methods/pages/_common/group-sort-order.md" %}}
```go-html-template
{{ 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:
```go-html-template
{{ range .Pages.GroupByParam "color" "desc" }}
<p>{{ .Key | title }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```

View File

@@ -0,0 +1,65 @@
---
title: GroupByParamDate
description: Returns the given page collection grouped by the given date parameter in descending order.
categories: []
keywords: []
action:
related:
- methods/pages/GroupByDate
- methods/pages/GroupByExpiryDate
- methods/pages/GroupByLastMod
- methods/pages/GroupByPublishDate
returnType: page.PagesGroup
signatures: ['PAGES.GroupByParamDate PARAM LAYOUT [SORT]']
---
The [layout string] has the same format as the layout string for the [`time.Format`] function. The resulting group key is [localized] for language and region.
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[localized]: /getting-started/glossary/#localization
{{% include "methods/pages/_common/group-sort-order.md" %}}
To group content by year and month:
```go-html-template
{{ range .Pages.GroupByParamDate "eventDate" "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
To sort the groups in ascending order:
```go-html-template
{{ range .Pages.GroupByParamDate "eventDate" "January 2006" "asc" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
The pages within each group will also be sorted by the parameter date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
```go-html-template
{{ range .Pages.GroupByParamDate "eventDate" "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages.ByTitle }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
```
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}

View File

@@ -0,0 +1,68 @@
---
title: GroupByPublishDate
description: Returns the given page collection grouped by publish date in descending order.
categories: []
keywords: []
action:
related:
- methods/pages/GroupByDate
- methods/pages/GroupByExpiryDate
- methods/pages/GroupByLastMod
- methods/pages/GroupByParamDate
returnType: page.PagesGroup
signatures: ['PAGES.GroupByPublishDate LAYOUT [SORT]']
---
When grouping by publish date, the value is determined by your [site configuration], defaulting to the `publishDate` field in front matter.
The [layout string] has the same format as the layout string for the [`time.Format`] function. The resulting group key is [localized] for language and region.
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[localized]: /getting-started/glossary/#localization
[site configuration]: /getting-started/configuration/#configure-dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
To group content by year and month:
```go-html-template
{{ range .Pages.GroupByPublishDate "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
To sort the groups in ascending order:
```go-html-template
{{ range .Pages.GroupByPublishDate "January 2006" "asc" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
```
The pages within each group will also be sorted by publish date, either ascending or descending depending on your grouping option. To sort the pages within each group, use one of the sorting methods. For example, to sort the pages within each group by title:
```go-html-template
{{ range .Pages.GroupByPublishDate "January 2006" }}
<p>{{ .Key }}</p>
<ul>
{{ range .Pages.ByTitle }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
```
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}

View File

@@ -0,0 +1,14 @@
---
title: Len
description: Returns the number of pages in the given page collection.
categories: []
keywords: []
action:
related: []
returnType: int
signatures: [PAGES.Len]
---
```go-html-template
{{ .Pages.Len }} → 42
```

View File

@@ -0,0 +1,16 @@
---
title: Limit
description: Returns the first N pages from the given page collection.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.Limit NUMBER]
---
```go-html-template
{{ range .Pages.Limit 3 }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,55 @@
---
title: Next
description: Returns the next page in a local page collection, relative to the given page.
categories: []
keywords: []
action:
related:
- methods/pages/Prev
- methods/page/Next
- methods/page/NextInSection
- methods/page/Prev
- methods/page/PrevInSection
returnType: hugolib.pageState
signatures: [PAGES.Next PAGE]
toc: true
---
The behavior of the `Prev` and `Next` methods on a `Pages` objects is probably the reverse of what you expect.
With this content structure and the page collection sorted by weight in ascending order:
```text
content/
├── pages/
│ ├── _index.md
│ ├── page-1.md <-- front matter: weight = 10
│ ├── page-2.md <-- front matter: weight = 20
│ └── page-3.md <-- front matter: weight = 30
└── _index.md
```
When you visit page-2:
- The `Prev` method points to page-3
- The `Next` method points to page-1
{{% note %}}
Use the opposite label in your navigation links as shown in the example below.
{{% /note %}}
```go-html-template
{{ $pages := where .Site.RegularPages.ByWeight "Section" "pages" }}
{{ with $pages.Next . }}
<a href="{{ .RelPermalink }}">Previous</a>
{{ end }}
{{ with $pages.Prev . }}
<a href="{{ .RelPermalink }}">Next</a>
{{ end }}
```
## Compare to Page methods
{{% include "methods/_common/next-prev-on-page-vs-next-prev-on-pages.md" %}}

View File

@@ -0,0 +1,55 @@
---
title: Prev
description: Returns the previous page in a local page collection, relative to the given page.
categories: []
keywords: []
action:
related:
- methods/pages/Next
- methods/page/Next
- methods/page/NextInSection
- methods/page/Prev
- methods/page/PrevInSection
returnType: hugolib.pageStates
signatures: [PAGES.Prev PAGE]
toc: true
---
The behavior of the `Prev` and `Next` methods on a `Pages` objects is probably the reverse of what you expect.
With this content structure and the page collection sorted by weight in ascending order:
```text
content/
├── pages/
│ ├── _index.md
│ ├── page-1.md <-- front matter: weight = 10
│ ├── page-2.md <-- front matter: weight = 20
│ └── page-3.md <-- front matter: weight = 30
└── _index.md
```
When you visit page-2:
- The `Prev` method points to page-3
- The `Next` method points to page-1
{{% note %}}
Use the opposite label in your navigation links as shown in the example below.
{{% /note %}}
```go-html-template
{{ $pages := where .Site.RegularPages.ByWeight "Section" "pages" }}
{{ with $pages.Next . }}
<a href="{{ .RelPermalink }}">Previous</a>
{{ end }}
{{ with $pages.Prev . }}
<a href="{{ .RelPermalink }}">Next</a>
{{ end }}
```
## Compare to Page methods
{{% include "methods/_common/next-prev-on-page-vs-next-prev-on-pages.md" %}}

View File

@@ -0,0 +1,79 @@
---
title: Related
description: Returns a collection of pages related to the given page.
categories: []
keywords: []
action:
related:
- methods/page/HeadingsFiltered
- functions/collections/KeyVals
returnType: page.Pages
signatures:
- PAGES.Related PAGE
- PAGES.Related OPTIONS
---
Based on front matter, Hugo uses several factors to identify content related to the given page. Use the default [related content configuration], or tune the results to the desired indices and parameters. See&nbsp;[details].
The argument passed to the `Related` method may be a `Page` or an options map. For example, to pass the current page:
{{< code file=layouts/_default/single.html >}}
{{ with .Site.RegularPages.Related . | first 5 }}
<p>Related pages:</p>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
{{< /code >}}
To pass an options map:
{{< code file=layouts/_default/single.html >}}
{{ $opts := dict
"document" .
"indices" (slice "tags" "keywords")
}}
{{ with .Site.RegularPages.Related $opts | first 5 }}
<p>Related pages:</p>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
{{< /code >}}
## Options
indices
: (`slice`) The indices to search within.
document
: (`page`) The page for which to find related content. Required when specifying an options map.
namedSlices
: (`slice`) The keywords to search for, expressed as a slice of `KeyValues` using the [`keyVals`] function.
[`keyVals`]: /functions/collections/keyvals/
fragments
: (`slice`) A list of special keywords that is used for indices configured as type "fragments". This will match the [fragment] identifiers of the documents.
A contrived example using all of the above:
```go-html-template
{{ $page := . }}
{{ $opts := dict
"indices" (slice "tags" "keywords")
"document" $page
"namedSlices" (slice (keyVals "tags" "hugo" "rocks") (keyVals "date" $page.Date))
"fragments" (slice "heading-1" "heading-2")
}}
```
[details]: /content-management/related/
[fragment]: /getting-started/glossary/#fragment
[related content configuration]: /content-management/related/

View File

@@ -0,0 +1,16 @@
---
title: Reverse
description: Returns the given page collection in reverse order.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.Reverse]
---
```go-html-template
{{ range .Pages.ByDate.Reverse }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

View File

@@ -0,0 +1,13 @@
---
cascade:
_build:
list: never
publishResources: false
render: never
---
<!--
Files within this headless branch bundle are markdown snippets. Each file must contain front matter delimiters, though front matter fields are not required.
Include the rendered content using the "include" shortcode.
-->

View File

@@ -0,0 +1,5 @@
---
# Do not remove front matter.
---
For the optional sort order, specify either `asc` for ascending order, or `desc` for descending order.

View File

@@ -0,0 +1,13 @@
---
title: Pages methods
linkTitle: Pages
description: Use these methods with a collection of Page objects.
categories: []
keywords: []
menu:
docs:
parent: methods
aliases: [/variables/pages]
---
Use these methods with a collection of Page objects.