Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'

This commit is contained in:
Bjørn Erik Pedersen
2025-04-10 13:04:51 +02:00
987 changed files with 12379 additions and 14083 deletions

View File

@@ -3,18 +3,15 @@ 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]
params:
functions_and_methods:
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
[site configuration]: /configuration/front-matter/#dates
```go-html-template
{{ range .Pages.ByDate }}

View File

@@ -3,18 +3,15 @@ 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]
params:
functions_and_methods:
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
[site configuration]: /configuration/front-matter/#dates
```go-html-template
{{ range .Pages.ByExpiryDate }}

View File

@@ -3,10 +3,10 @@ title: ByLanguage
description: Returns the given page collection sorted by language in ascending order.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.ByLanguage]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.ByLanguage]
---
```go-html-template

View File

@@ -3,18 +3,15 @@ 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]
params:
functions_and_methods:
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
[site configuration]: /configuration/front-matter/#dates
```go-html-template
{{ range .Pages.ByLastmod }}

View File

@@ -3,10 +3,10 @@ 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]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.ByLength]
---
```go-html-template

View File

@@ -3,12 +3,10 @@ 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]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.ByLinkTitle]
---
```go-html-template

View File

@@ -3,12 +3,10 @@ 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]
params:
functions_and_methods:
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.

View File

@@ -3,18 +3,15 @@ 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]
params:
functions_and_methods:
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
[site configuration]: /configuration/front-matter/#dates
```go-html-template
{{ range .Pages.ByPublishDate }}

View File

@@ -3,12 +3,10 @@ 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]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.ByTitle]
---
```go-html-template

View File

@@ -3,10 +3,10 @@ title: ByWeight
description: Returns the given page collection sorted by weight in ascending order.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.ByWeight]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.ByWeight]
---
Assign a [weight](g) 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.

View File

@@ -3,13 +3,13 @@ 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]']
params:
functions_and_methods:
returnType: page.PagesGroup
signatures: ['PAGES.GroupBy FIELD [SORT]']
---
{{% include "methods/pages/_common/group-sort-order.md" %}}
{{% include "/_common/methods/pages/group-sort-order.md" %}}
```go-html-template
{{ range .Pages.GroupBy "Section" }}

View File

@@ -3,14 +3,10 @@ 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]']
params:
functions_and_methods:
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.
@@ -19,9 +15,9 @@ The [layout string] has the same format as the layout string for the [`time.Form
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[site configuration]: /getting-started/configuration/#configure-dates
[site configuration]: /configuration/front-matter/#dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
{{% include "/_common/methods/pages/group-sort-order.md" %}}
To group content by year and month:
@@ -64,4 +60,4 @@ The pages within each group will also be sorted by date, either ascending or des
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
{{% include "/_common/time-layout-string.md" %}}

View File

@@ -3,14 +3,10 @@ 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]']
params:
functions_and_methods:
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.
@@ -19,9 +15,9 @@ The [layout string] has the same format as the layout string for the [`time.Form
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[site configuration]: /getting-started/configuration/#configure-dates
[site configuration]: /configuration/front-matter/#dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
{{% include "/_common/methods/pages/group-sort-order.md" %}}
To group content by year and month:
@@ -64,4 +60,4 @@ The pages within each group will also be sorted by expiration date, either ascen
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
{{% include "/_common/time-layout-string.md" %}}

View File

@@ -3,14 +3,10 @@ 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]']
params:
functions_and_methods:
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.
@@ -19,9 +15,9 @@ The [layout string] has the same format as the layout string for the [`time.Form
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[site configuration]: /getting-started/configuration/#configure-dates
[site configuration]: /configuration/front-matter/#dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
{{% include "/_common/methods/pages/group-sort-order.md" %}}
To group content by year and month:
@@ -64,4 +60,4 @@ The pages within each group will also be sorted by last modification date, eithe
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
{{% include "/_common/time-layout-string.md" %}}

View File

@@ -3,13 +3,13 @@ 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]']
params:
functions_and_methods:
returnType: page.PagesGroup
signatures: ['PAGES.GroupByParam PARAM [SORT]']
---
{{% include "methods/pages/_common/group-sort-order.md" %}}
{{% include "/_common/methods/pages/group-sort-order.md" %}}
```go-html-template
{{ range .Pages.GroupByParam "color" }}

View File

@@ -3,14 +3,10 @@ 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]']
params:
functions_and_methods:
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](g) for language and region.
@@ -18,7 +14,7 @@ The [layout string] has the same format as the layout string for the [`time.Form
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
{{% include "methods/pages/_common/group-sort-order.md" %}}
{{% include "/_common/methods/pages/group-sort-order.md" %}}
To group content by year and month:
@@ -61,4 +57,4 @@ The pages within each group will also be sorted by the parameter date, either as
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
{{% include "/_common/time-layout-string.md" %}}

View File

@@ -3,14 +3,10 @@ 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]']
params:
functions_and_methods:
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.
@@ -19,9 +15,9 @@ The [layout string] has the same format as the layout string for the [`time.Form
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[site configuration]: /getting-started/configuration/#configure-dates
[site configuration]: /configuration/front-matter/#dates
{{% include "methods/pages/_common/group-sort-order.md" %}}
{{% include "/_common/methods/pages/group-sort-order.md" %}}
To group content by year and month:
@@ -64,4 +60,4 @@ The pages within each group will also be sorted by publish date, either ascendin
## Layout string
{{% include "functions/_common/time-layout-string.md" %}}
{{% include "/_common/time-layout-string.md" %}}

View File

@@ -3,10 +3,10 @@ title: Len
description: Returns the number of pages in the given page collection.
categories: []
keywords: []
action:
related: []
returnType: int
signatures: [PAGES.Len]
params:
functions_and_methods:
returnType: int
signatures: [PAGES.Len]
---
```go-html-template

View File

@@ -3,10 +3,10 @@ title: Limit
description: Returns the first N pages from the given page collection.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.Limit NUMBER]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.Limit NUMBER]
---
```go-html-template

View File

@@ -3,15 +3,10 @@ title: Next
description: Returns the next page in a page collection, relative to the given page.
categories: []
keywords: []
action:
related:
- methods/pages/Prev
- methods/page/Next
- methods/page/Prev
- methods/page/NextInSection
- methods/page/PrevInSection
returnType: page.Page
signatures: [PAGES.Next PAGE]
params:
functions_and_methods:
returnType: page.Page
signatures: [PAGES.Next PAGE]
---
{{% include "methods/pages/_common/next-and-prev.md" %}}
{{% include "/_common/methods/pages/next-and-prev.md" %}}

View File

@@ -3,15 +3,10 @@ title: Prev
description: Returns the previous page in a page collection, relative to the given page.
categories: []
keywords: []
action:
related:
- methods/pages/Next
- methods/page/Next
- methods/page/Prev
- methods/page/NextInSection
- methods/page/PrevInSection
returnType: page.Pages
signatures: [PAGES.Prev PAGE]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.Prev PAGE]
---
{{% include "methods/pages/_common/next-and-prev.md" %}}
{{% include "/_common/methods/pages/next-and-prev.md" %}}

View File

@@ -3,21 +3,19 @@ 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
params:
functions_and_methods:
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 [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 >}}
```go-html-template {file="layouts/_default/single.html"}
{{ with .Site.RegularPages.Related . | first 5 }}
<p>Related pages:</p>
<ul>
@@ -26,11 +24,11 @@ The argument passed to the `Related` method may be a `Page` or an options map. F
{{ end }}
</ul>
{{ end }}
{{< /code >}}
```
To pass an options map:
{{< code file=layouts/_default/single.html >}}
```go-html-template {file="layouts/_default/single.html"}
{{ $opts := dict
"document" .
"indices" (slice "tags" "keywords")
@@ -43,7 +41,7 @@ To pass an options map:
{{ end }}
</ul>
{{ end }}
{{< /code >}}
```
## Options
@@ -73,5 +71,5 @@ A contrived example using all of the above:
}}
```
[details]: /content-management/related/
[related content configuration]: /content-management/related/
[details]: /content-management/related-content/
[related content configuration]: /configuration/related-content/

View File

@@ -3,10 +3,10 @@ title: Reverse
description: Returns the given page collection in reverse order.
categories: []
keywords: []
action:
related: []
returnType: page.Pages
signatures: [PAGES.Reverse]
params:
functions_and_methods:
returnType: page.Pages
signatures: [PAGES.Reverse]
---
```go-html-template

View File

@@ -1,13 +0,0 @@
---
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

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

View File

@@ -1,72 +0,0 @@
---
_comment: Do not remove front matter.
---
Hugo determines the _next_ and _previous_ page by sorting the page collection according to this sorting hierarchy:
Field|Precedence|Sort direction
:--|:--|:--
[`weight`]|1|descending
[`date`]|2|descending
[`linkTitle`]|3|descending
[`path`]|4|descending
[`date`]: /methods/page/date/
[`weight`]: /methods/page/weight/
[`linkTitle`]: /methods/page/linktitle/
[`path`]: /methods/page/path/
The sorted page collection used to determine the _next_ and _previous_ page is independent of other page collections, which may lead to unexpected behavior.
For example, with this content structure:
```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
```
And these templates:
{{< code file=layouts/_default/list.html >}}
{{ range .Pages.ByWeight}}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
{{< /code >}}
{{< code file=layouts/_default/single.html >}}
{{ $pages := .CurrentSection.Pages.ByWeight }}
{{ with $pages.Prev . }}
<a href="{{ .RelPermalink }}">Previous</a>
{{ end }}
{{ with $pages.Next . }}
<a href="{{ .RelPermalink }}">Next</a>
{{ end }}
{{< /code >}}
When you visit page-2:
- The `Prev` method points to page-3
- The `Next` method points to page-1
To reverse the meaning of _next_ and _previous_ you can chain the [`Reverse`] method to the page collection definition:
{{< code file=layouts/_default/single.html >}}
{{ $pages := .CurrentSection.Pages.ByWeight.Reverse }}
{{ with $pages.Prev . }}
<a href="{{ .RelPermalink }}">Previous</a>
{{ end }}
{{ with $pages.Next . }}
<a href="{{ .RelPermalink }}">Next</a>
{{ end }}
{{< /code >}}
[`Reverse`]: /methods/pages/reverse/

View File

@@ -4,10 +4,5 @@ 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.