Merge commit '346b60358dd8ec2ca228e6635bff9d7914b398b7'

This commit is contained in:
Bjørn Erik Pedersen
2025-01-23 09:47:46 +01:00
384 changed files with 3305 additions and 3271 deletions

View File

@@ -10,7 +10,7 @@ action:
signatures: [PAGE.AlternativeOutputFormats]
---
{{% include "methods/page/_common/output-format-definition.md" %}}
{{% glossary-term "output format" %}}
The `AlternativeOutputFormats` method on a `Page` object returns a slice of `OutputFormat` objects, excluding the current output format, each representing one of the output formats enabled for the given page.. See [details](/templates/output-formats/).

View File

@@ -9,7 +9,7 @@ action:
signatures: [PAGE.BundleType]
---
A page bundle is a directory that encapsulates both content and associated [resources]. There are two types of page bundles: [leaf bundles] and [branch bundles]. See [details](/content-management/page-bundles/).
A page bundle is a directory that encapsulates both content and associated [resources](g). There are two types of page bundles: [leaf bundles](g) and [branch bundles](g). See [details](/content-management/page-bundles/).
The `BundleType` method on a `Page` object returns `branch` for branch bundles, `leaf` for leaf bundles, and an empty string if the page is not a page bundle.
@@ -31,7 +31,3 @@ To get the value within a template:
```go-html-template
{{ .BundleType }}
```
[resources]: /getting-started/glossary/#resource
[leaf bundles]: /getting-started/glossary/#leaf-bundle
[branch bundles]: /getting-started/glossary/#branch-bundle

View File

@@ -19,11 +19,7 @@ action:
{{% include "methods/page/_common/definition-of-section.md" %}}
{{% note %}}
The current section of a [section] page, [taxonomy] page, [term] page, or the home page, is itself.
[section]: /getting-started/glossary/#section
[taxonomy]: /getting-started/glossary/#taxonomy
[term]: /getting-started/glossary/#term
The current section of a [section page](g), [taxonomy page](g), [term page](g), or the home page, is itself.
{{% /note %}}
Consider this content structure:

View File

@@ -10,20 +10,16 @@ action:
toc: true
---
The `Data` method on a `Page` object returns a unique data object for each [page kind].
[page kind]: /getting-started/glossary/#page-kind
The `Data` method on a `Page` object returns a unique data object for each [page kind](g).
{{% note %}}
The `Data` method is only useful within [taxonomy] and [term] templates.
The `Data` method is only useful within [taxonomy](g) and [term](g) templates.
Themes that are not actively maintained may still use `.Data.Pages` in list templates. Although that syntax remains functional, use one of these methods instead: [`Pages`], [`RegularPages`], or [`RegularPagesRecursive`]
[`Pages`]: /methods/page/pages/
[`RegularPages`]: /methods/page/regularpages/
[`RegularPagesRecursive`]: /methods/page/regularpagesrecursive/
[term]: /getting-started/glossary/#term
[taxonomy]: /getting-started/glossary/#taxonomy
{{% /note %}}
The examples that follow are based on this site configuration:
@@ -65,7 +61,7 @@ Plural
```
Terms
: (`page.Taxonomy`) Returns the `Taxonomy` object, consisting of a map of terms and the [weighted pages] associated with each term.
: (`page.Taxonomy`) Returns the `Taxonomy` object, consisting of a map of terms and the [weighted pages](g) associated with each term.
```go-html-template
{{ $taxonomyObject := .Data.Terms }}
@@ -108,4 +104,3 @@ Learn more about [term templates].
[taxonomy templates]: /templates/types/#taxonomy
[term templates]: /templates/types/#term
[weighted pages]: /getting-started/glossary/#weighted-page

View File

@@ -10,9 +10,9 @@ action:
toc: true
---
By default, not all pages are backed by a file, including top level [section] pages, [taxonomy] pages, and [term] pages. By definition, you cannot retrieve file information when the file does not exist.
By default, not all pages are backed by a file, including top level [section pages](g), [taxonomy pages](g), and [term pages](g). By definition, you cannot retrieve file information when the file does not exist.
To back one of the pages above with a file, create an _index.md file in the corresponding directory. For example:
To back one of the pages above with a file, create an `_index.md` file in the corresponding directory. For example:
```text
content/
@@ -195,7 +195,3 @@ Without a backing file, Hugo will throw an error if you attempt to access a `.Fi
{{ .ContentBaseName }}
{{ end }}
```
[section]: /getting-started/glossary/#section
[taxonomy]: /getting-started/glossary/#taxonomy
[term]: /getting-started/glossary/#term

View File

@@ -11,9 +11,7 @@ action:
toc: true
---
{{< new-in 0.111.0 >}}
In a URL, whether absolute or relative, the [fragment] links to an `id` attribute of an HTML element on the page.
In a URL, whether absolute or relative, the [fragment](g) links to an `id` attribute of an HTML element on the page.
```text
/articles/article-1#section-2
@@ -21,9 +19,9 @@ In a URL, whether absolute or relative, the [fragment] links to an `id` attribut
path fragment
```
Hugo assigns an `id` attribute to each Markdown [ATX] and [setext] heading within the page content. You can override the `id` with a [Markdown attribute] as needed. This creates the relationship between an entry in the [table of contents] (TOC) and a heading on the page.
Hugo assigns an `id` attribute to each Markdown [ATX] and [setext] heading within the page content. You can override the `id` with a [Markdown attribute](g) as needed. This creates the relationship between an entry in the [table of contents] (TOC) and a heading on the page.
Use the `Fragments` method on a `Page` object to create a table of contents with the `Fragments.ToHTML` method, or by [walking] the `Fragments.Map` data structure.
Use the `Fragments` method on a `Page` object to create a table of contents with the `Fragments.ToHTML` method, or by [walking](g) the `Fragments.Map` data structure.
## Methods
@@ -34,7 +32,6 @@ Headings
<pre>{{ debug.Dump .Fragments.Headings }}</pre>
```
HeadingsMap
: (`map`) A nested map of all headings on the page. Each map contains the following keys: `ID`, `Level`, `Title` and `Headings`. To inspect the data structure:
@@ -50,7 +47,7 @@ Identifiers
```
Identifiers.Contains ID
: (`bool`) Reports whether one or more headings on the page has the given `id` attribute, useful for validating fragments within a link [render hook].
: (`bool`) Reports whether one or more headings on the page has the given `id` attribute, useful for validating fragments within a link [render hook](g).
```go-html-template
{{ .Fragments.Identifiers.Contains "section-2" }} → true
@@ -98,10 +95,6 @@ When using the `Fragments` methods within a shortcode, call the shortcode using
{{% /note %}}
[atx]: https://spec.commonmark.org/0.30/#atx-headings
[fragment]: /getting-started/glossary/#fragment
[markdown attribute]: /getting-started/glossary/#markdown-attribute
[setext]: https://spec.commonmark.org/0.30/#setext-headings
[table of contents]: /methods/page/tableofcontents/
[walking]: /getting-started/glossary/#walk
[`tableofcontents`]: /methods/page/tableofcontents/
[render hook]: /getting-started/glossary/#render-hook

View File

@@ -15,7 +15,7 @@ The `GetPage` method is also available on a `Site` object. See&nbsp;[details].
[details]: /methods/site/getpage/
When using the `GetPage` method on the `Page` object, specify a path relative to the current directory or relative to the content directory.
When using the `GetPage` method on the `Page` object, specify a path relative to the current directory or relative to the `content` directory.
If Hugo cannot resolve the path to a page, the method returns nil. If the path is ambiguous, Hugo throws an error and fails the build.

View File

@@ -73,7 +73,7 @@ In the examples above we are coding defensively using the [`with`] statement, re
## Understanding context
Inside of the `with` block, the [context] (the dot) is the section `Page` object, not the `Page` object passed into the template. If we were to use this syntax:
Inside of the `with` block, the [context](g) (the dot) is the section `Page` object, not the `Page` object passed into the template. If we were to use this syntax:
```go-html-template
{{ with .Site.GetPage "/auctions" }}
@@ -97,6 +97,5 @@ Use the `$` to get the context passed into the template.
Gaining a thorough understanding of context is critical for anyone writing template code.
{{% /note %}}
[context]: /getting-started/glossary/#context
[`with`]: /functions/go-template/with/
[`else`]: /functions/go-template/else/

View File

@@ -71,7 +71,7 @@ In the examples above we are coding defensively using the [`with`] statement, re
## Understanding context
Inside of the `with` block, the [context] (the dot) is the section `Page` object, not the `Page` object passed into the template. If we were to use this syntax:
Inside of the `with` block, the [context](g) (the dot) is the section `Page` object, not the `Page` object passed into the template. If we were to use this syntax:
```go-html-template
{{ with .Site.GetPage "/auctions" }}
@@ -95,6 +95,5 @@ Use the `$` to get the context passed into the template.
Gaining a thorough understanding of context is critical for anyone writing template code.
{{% /note %}}
[context]: /getting-started/glossary/#context
[`with`]: /functions/go-template/with/
[`else`]: /functions/go-template/else/

View File

@@ -70,7 +70,7 @@ In the examples above we are coding defensively using the [`with`] statement, re
## Understanding context
Inside of the `with` block, the [context] (the dot) is the section `Page` object, not the `Page` object passed into the template. If we were to use this syntax:
Inside of the `with` block, the [context](g) (the dot) is the section `Page` object, not the `Page` object passed into the template. If we were to use this syntax:
```go-html-template
{{ with .Site.GetPage "/auctions" }}
@@ -94,6 +94,5 @@ Use the `$` to get the context passed into the template.
Gaining a thorough understanding of context is critical for anyone writing template code.
{{% /note %}}
[context]: /getting-started/glossary/#context
[`with`]: /functions/go-template/with/
[`else`]: /functions/go-template/else/

View File

@@ -12,7 +12,7 @@ action:
signatures: [PAGE.IsHome]
---
The `IsHome` method on a `Page` object returns `true` if the [page kind] is `home`.
The `IsHome` method on a `Page` object returns `true` if the [page kind](g) is `home`.
```text
content/
@@ -27,5 +27,3 @@ content/
```go-html-template
{{ .IsHome }}
```
[page kind]: /getting-started/glossary/#page-kind

View File

@@ -12,7 +12,7 @@ action:
signatures: [PAGE.IsNode]
---
The `IsNode` method on a `Page` object returns `true` if the [page kind] is `home`, `section`, `taxonomy`, or `term`.
The `IsNode` method on a `Page` object returns `true` if the [page kind](g) is `home`, `section`, `taxonomy`, or `term`.
It returns `false` is the page kind is `page`.
@@ -33,4 +33,3 @@ content/
```go-html-template
{{ .IsNode }}
```
[page kind]: /getting-started/glossary/#page-kind

View File

@@ -12,7 +12,7 @@ action:
signatures: [PAGE.IsPage]
---
The `IsPage` method on a `Page` object returns `true` if the [page kind] is `page`.
The `IsPage` method on a `Page` object returns `true` if the [page kind](g) is `page`.
```text
content/
@@ -27,5 +27,3 @@ content/
```go-html-template
{{ .IsPage }}
```
[page kind]: /getting-started/glossary/#page-kind

View File

@@ -12,7 +12,7 @@ action:
signatures: [PAGE.IsSection]
---
The `IsSection` method on a `Page` object returns `true` if the [page kind] is `section`.
The `IsSection` method on a `Page` object returns `true` if the [page kind](g) is `section`.
```text
content/
@@ -27,5 +27,3 @@ content/
```go-html-template
{{ .IsSection }}
```
[page kind]: /getting-started/glossary/#page-kind

View File

@@ -46,13 +46,13 @@ content/
└── _index.md
```
When rendering content/en/books/book-1.md:
When rendering `content/en/books/book-1.md`:
```go-html-template
{{ .IsTranslated }} → true
```
When rendering content/en/books/book-2.md:
When rendering `content/en/books/book-2.md`:
```go-html-template
{{ .IsTranslated }} → false

View File

@@ -10,7 +10,7 @@ action:
signatures: [PAGE.Kind]
---
The [page kind] is one of `home`, `page`, `section`, `taxonomy`, or `term`.
The [page kind](g) is one of `home`, `page`, `section`, `taxonomy`, or `term`.
```text
content/
@@ -31,5 +31,3 @@ To get the value within a template:
```go-html-template
{{ .Kind }}
```
[page kind]: /getting-started/glossary/#page-kind

View File

@@ -11,7 +11,7 @@ action:
toc: true
---
{{% include "methods/page/_common/output-format-definition.md" %}}
{{% glossary-term "output format" %}}
The `OutputFormats` method on a `Page` object returns a slice of `OutputFormat` objects, each representing one of the output formats enabled for the given page. See&nbsp;[details](/templates/output-formats/).

View File

@@ -9,13 +9,13 @@ action:
signatures: [PAGE.Page]
---
This is a convenience method, useful within partial templates that are called from both [shortcodes] and page templates.
This is a convenience method, useful within partial templates that are called from both [shortcodes](g) and page templates.
{{< code file=layouts/shortcodes/foo.html >}}
{{ partial "my-partial.html" . }}
{{< /code >}}
When the shortcode calls the partial, it passes the current [context] (the dot). The context includes identifiers such as `Page`, `Params`, `Inner`, and `Name`.
When the shortcode calls the partial, it passes the current [context](g) (the dot). The context includes identifiers such as `Page`, `Params`, `Inner`, and `Name`.
{{< code file=layouts/_default/single.html >}}
{{ partial "my-partial.html" . }}
@@ -34,7 +34,3 @@ And yes, that means you can do `.Page.Page.Page.Page.Title` too.
But don't.
{{% /note %}}
[context]: getting-started/glossary/#context
[shortcodes]: /getting-started/glossary/#shortcode

View File

@@ -11,7 +11,7 @@ action:
signatures: [PAGE.Pages]
---
The `Pages` method on a `Page` object is available to these [page kinds]: `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection] in [context].
The `Pages` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g).
Range through the page collection in your template:
@@ -70,7 +70,7 @@ When rendering lesson-2, the `Pages` method returns:
lessons/lesson-2/resources/task-list.md
lessons/lesson-2/resources/worksheet.md
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section]---it does not contain an _index.md file. Its contents are part of the lesson-2 section.
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an `_index.md` file. Its contents are part of the lesson-2 section.
{{% note %}}
When used with a `Site` object, the `Pages` method recursively returns all pages within the site. See&nbsp;[details].
@@ -83,8 +83,3 @@ When used with a `Site` object, the `Pages` method recursively returns all pages
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
```
[collection]: /getting-started/glossary/#collection
[context]: /getting-started/glossary/#context
[page kinds]: /getting-started/glossary/#page-kind
[section]: /getting-started/glossary/#section

View File

@@ -41,10 +41,10 @@ You can invoke pagination on the [home template], [section templates], [taxonomy
In the example above, we:
1. Build a page collection
2. Sort the collection by title
3. Paginate the collection, with 7 elements per pager
4. Range over the paginated page collection, rendering a link to each page
5. Call the embedded pagination template to create navigation links between pagers
1. Sort the collection by title
1. Paginate the collection, with 7 elements per pager
1. Range over the paginated page collection, rendering a link to each page
1. Call the embedded pagination template to create navigation links between pagers
{{% note %}}
Please note that the results of pagination are cached. Once you have invoked either the `Paginator` or `Paginate` method, the paginated collection is immutable. Additional invocations of these methods will have no effect.

View File

@@ -16,13 +16,12 @@ The number of elements on each pager is determined by your [site configuration].
[site configuration]: /getting-started/configuration/#pagination
You can invoke pagination on the [home template], [section templates], [taxonomy templates], and [term templates]. Each of these receives a collection of regular pages in [context]. When you invoke the `Paginator` method, it paginates the page collection received in context.
You can invoke pagination on the [home template], [section templates], [taxonomy templates], and [term templates]. Each of these receives a collection of regular pages in [context](g). When you invoke the `Paginator` method, it paginates the page collection received in context.
[home template]: /templates/types/#home
[section templates]: /templates/types/#section
[taxonomy templates]: /templates/types/#taxonomy
[term templates]: /templates/types/#term
[context]: /getting-started/glossary/#context
{{< code file=layouts/_default/list.html >}}
{{ range .Paginator.Pages }}

View File

@@ -26,7 +26,7 @@ display_related = true
The `title` and `date` fields are standard parameters---the other fields are user-defined.
Access the custom parameters by [chaining] the [identifiers]:
Access the custom parameters by [chaining](g) the [identifiers](g):
```go-html-template
{{ .Params.display_related }} → true
@@ -40,5 +40,3 @@ In the template example above, each of the keys is a valid identifier. For examp
```
[`index`]: /functions/collections/indexfunction/
[chaining]: /getting-started/glossary/#chain
[identifiers]: /getting-started/glossary/#identifier

View File

@@ -14,9 +14,7 @@ toc: true
{{< new-in 0.123.0 >}}
The `Path` method on a `Page` object returns the logical path of the given page, regardless of whether the page is backed by a file.
[logical path]: /getting-started/glossary#logical-path
The `Path` method on a `Page` object returns the [logical path](g) of the given page, regardless of whether the page is backed by a file.
```go-html-template
{{ .Path }} → /posts/post-1
@@ -33,12 +31,12 @@ The meaning of, and value returned by, the `Path` method on a `Page` object chan
[v0.123.0]: https://github.com/gohugoio/hugo/releases/tag/v0.123.0
{{% /note %}}
To determine the logical path for pages backed by a file, Hugo starts with the file path, relative to the content directory, and then:
To determine the logical path for pages backed by a file, Hugo starts with the file path, relative to the `content` directory, and then:
1. Strips the file extension
2. Strips the language identifier
3. Converts the result to lower case
4. Replaces spaces with hyphens
1. Strips the language identifier
1. Converts the result to lower case
1. Replaces spaces with hyphens
The value returned by the `Path` method on a `Page` object is independent of content format, language, and URL modifiers such as the `slug` and `url` front matter fields.
@@ -112,8 +110,8 @@ Methods|Functions|Shortcodes
[`urls.RelRef`]: /functions/urls/relref/
[`Page.GetPage`]: /methods/page/getpage/
[`Site.GetPage`]: /methods/site/getpage/
[`ref`]: /content-management/shortcodes/#ref
[`relref`]: /content-management/shortcodes/#relref
[`ref`]: /shortcodes/ref/
[`relref`]: /shortcodes/relref/
[`Page.Ref`]: /methods/page/ref/
[`Page.RelRef`]: /methods/page/relref/
[`Shortcode.Ref`]: /methods/shortcode/ref
@@ -123,7 +121,6 @@ Methods|Functions|Shortcodes
Specify the logical path when using any of these methods, functions, or shortcodes. If you include a file extension or language identifier, Hugo will strip these values before finding the page in the logical tree.
{{% /note %}}
## Logical tree
Just as file paths form a file tree, logical paths form a logical tree.

View File

@@ -15,7 +15,7 @@ action:
signatures: [PAGE.Plain]
---
The `Plain` method on a `Page` object renders Markdown and [shortcodes] to HTML, then strips the HTML [tags]. It does not strip HTML [entities].
The `Plain` method on a `Page` object renders Markdown and [shortcodes](g) to HTML, then strips the HTML [tags]. It does not strip HTML [entities].
To prevent Go's [html/template] package from escaping HTML entities, pass the result through the [`htmlUnescape`] function.
@@ -23,7 +23,6 @@ To prevent Go's [html/template] package from escaping HTML entities, pass the re
{{ .Plain | htmlUnescape }}
```
[shortcodes]: /getting-started/glossary/#shortcode
[html/template]: https://pkg.go.dev/html/template
[entities]: https://developer.mozilla.org/en-US/docs/Glossary/Entity
[tags]: https://developer.mozilla.org/en-US/docs/Glossary/Tag

View File

@@ -24,9 +24,8 @@ The `RawContent` method on a `Page` object returns the raw content. The raw cont
This is useful when rendering a page in a plain text [output format].
{{% note %}}
[Shortcodes] within the content are not rendered. To get the raw content with shortcodes rendered, use the [`RenderShortcodes`] method on a `Page` object.
[Shortcodes](g) within the content are not rendered. To get the raw content with shortcodes rendered, use the [`RenderShortcodes`] method on a `Page` object.
[shortcodes]: /getting-started/glossary/#shortcode
[`RenderShortcodes`]: /methods/page/rendershortcodes/
{{% /note %}}

View File

@@ -15,7 +15,7 @@ action:
The map of option contains:
path
: (`string`) The path to the page, relative to the content directory. Required.
: (`string`) The path to the page, relative to the `content` directory. Required.
lang
: (`string`) The language (site) to search for the page. Default is the current language. Optional.

View File

@@ -11,7 +11,7 @@ action:
signatures: [PAGE.RegularPages]
---
The `RegularPages` method on a `Page` object is available to these [page kinds]: `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection] in [context].
The `RegularPages` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g).
Range through the page collection in your template:
@@ -67,7 +67,7 @@ When rendering lesson-2, the `RegularPages` method returns:
lessons/lesson-2/resources/task-list.md
lessons/lesson-2/resources/worksheet.md
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section]---it does not contain an _index.md file. Its contents are part of the lesson-2 section.
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an _index.md file. Its contents are part of the lesson-2 section.
{{% note %}}
When used with the `Site` object, the `RegularPages` method recursively returns all regular pages within the site. See&nbsp;[details].
@@ -80,8 +80,3 @@ When used with the `Site` object, the `RegularPages` method recursively returns
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}
```
[collection]: /getting-started/glossary/#collection
[context]: /getting-started/glossary/#context
[page kinds]: /getting-started/glossary/#page-kind
[section]: /getting-started/glossary/#section

View File

@@ -11,7 +11,7 @@ action:
signatures: [PAGE.RegularPagesRecursive]
---
The `RegularPagesRecursive` method on a `Page` object is available to these [page kinds]: `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection] in [context].
The `RegularPagesRecursive` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g).
Range through the page collection in your template:
@@ -84,7 +84,3 @@ When rendering lesson-2, the `RegularPagesRecursive` method returns:
{{% note %}}
The `RegularPagesRecursive` method in not available on a `Site` object.
{{% /note %}}
[collection]: /getting-started/glossary/#collection
[context]: /getting-started/glossary/#context
[page kinds]: /getting-started/glossary/#page-kind

View File

@@ -15,7 +15,7 @@ action:
The map of option contains:
path
: (`string`) The path to the page, relative to the content directory. Required.
: (`string`) The path to the page, relative to the `content` directory. Required.
lang
: (`string`) The language (site) to search for the page. Default is the current language. Optional.

View File

@@ -28,7 +28,7 @@ Although similar to the [`partial`] function, there are key differences.
`Render` method|`partial` function|
:--|:--
The `Page` object is automatically passed to the given template. You cannot pass additional context.| You must specify the context, allowing you to pass a combination of objects, slices, maps, and scalars.
The path to the template is determined by the [content type].|You must specify the path to the template, relative to the layouts/partials directory.
The path to the template is determined by the [content type](g).|You must specify the path to the template, relative to the `layouts/partials` directory.
Consider this layout structure:
@@ -72,4 +72,3 @@ See [content views] for more examples.
[content views]: /templates/content-view/
[`partial`]: /functions/partials/include/
[content type]: /getting-started/glossary/#content-type

View File

@@ -86,7 +86,6 @@ An *emphasized* word.
Note that the shortcode within the content file was rendered, but the surrounding Markdown was preserved.
## Limitations
The primary use case for `.RenderShortcodes` is inclusion of Markdown content. If you try to use `.RenderShortcodes` inside `HTML` blocks when inside Markdown, you will get a warning similar to this:

View File

@@ -15,7 +15,7 @@ action:
toc: true
---
The `Resources` method on a `Page` object returns a collection of page resources. A page resource is a file within a [page bundle].
The `Resources` method on a `Page` object returns a collection of page resources. A page resource is a file within a [page bundle](g).
To work with global or remote resources, see the [`resources`] functions.
@@ -82,7 +82,6 @@ When working with global resources instead of page resources, use the [`resource
This method is currently only useful in [js.Batch](/functions/js/batch/#import-context).
## Pattern matching
With the `GetMatch` and `Match` methods, Hugo determines a match using a case-insensitive [glob pattern].
@@ -96,4 +95,3 @@ With the `GetMatch` and `Match` methods, Hugo determines a match using a case-in
[`resources`]: /functions/resources/
[glob pattern]: https://github.com/gobwas/glob#example
[media type]: https://en.wikipedia.org/wiki/Media_type
[page bundle]: /getting-started/glossary/#page-bundle

View File

@@ -11,6 +11,7 @@ action:
signatures: [PAGE.Scratch]
toc: true
aliases: [/extras/scratch/,/doc/scratch/,/functions/scratch]
expiryDate: 2025-11-18 # deprecated 2024-11-18
---
{{% deprecated-in 0.138.0 %}}
@@ -23,13 +24,12 @@ Beginning with v0.138.0 the `PAGE.Scratch` method is aliased to `PAGE.Store`.
[`PAGE.Store`]: /methods/page/store/
{{% /deprecated-in %}}
The `Scratch` method on a `Page` object creates a [scratch pad] to store and manipulate data. To create a scratch pad that is not reset on server rebuilds, use the [`Store`] method instead.
The `Scratch` method on a `Page` object creates a [scratch pad](g) to store and manipulate data. To create a scratch pad that is not reset on server rebuilds, use the [`Store`] method instead.
To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
[`Store`]: /methods/page/store/
[`newScratch`]: /functions/collections/newscratch/
[scratch pad]: /getting-started/glossary/#scratch-pad
{{% include "methods/page/_common/scratch-methods.md" %}}
@@ -37,9 +37,7 @@ To create a locally scoped scratch pad that is not attached to a `Page` object,
The `Scratch` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop] variable:
[noop]: /getting-started/glossary/#noop
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable:
```go-html-template
{{ $noop := .Content }}

View File

@@ -49,6 +49,5 @@ This is similar to using the [`Type`] method with the `where` function
However, if the `type` field in front matter has been defined on one or more pages, the page collection based on `Type` will be different than the page collection based on `Section`.
[`where`]: /functions/collections/where/
[`Type`]: /methods/page/type/

View File

@@ -16,11 +16,10 @@ toc: true
aliases: [/functions/store]
---
The `Store` method on a `Page` object creates a persistent [scratch pad] to store and manipulate data. To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
The `Store` method on a `Page` object creates a persistent [scratch pad](g) to store and manipulate data. To create a locally scoped scratch pad that is not attached to a `Page` object, use the [`newScratch`] function.
[`Scratch`]: /methods/page/scratch/
[`newScratch`]: /functions/collections/newscratch/
[scratch pad]: /getting-started/glossary/#scratch-pad
## Methods
@@ -109,9 +108,7 @@ Removes the given key.
The `Store` method is often used to set scratch pad values within a shortcode, a partial template called by a shortcode, or by a Markdown render hook. In all three cases, the scratch pad values are indeterminate until Hugo renders the page content.
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop] variable:
[noop]: /getting-started/glossary/#noop
If you need to access a scratch pad value from a parent template, and the parent template has not yet rendered the page content, you can trigger content rendering by assigning the returned value to a [noop](g) variable:
```go-html-template
{{ $noop := .Content }}

View File

@@ -13,10 +13,9 @@ action:
signatures: [PAGE.Summary]
---
{{% comment %}}
Do not remove the manual summary divider below.
If you do, you will break its first literal usage on this page.
{{% /comment %}}
<!-- Do not remove the manual summary divider below. -->
<!-- If you do, you will break its first literal usage on this page. -->
<!--more-->
You can define a [summary] manually, in front matter, or automatically. A manual summary takes precedence over a front matter summary, and a front matter summary takes precedence over an automatic summary.

View File

@@ -12,7 +12,7 @@ action:
signatures: [PAGE.Type]
---
The `Type` method on a `Page` object returns the [content type] of the given page. The content type is defined by the `type` field in front matter, or inferred from the top-level directory name if the `type` field in front matter is not defined.
The `Type` method on a `Page` object returns the [content type](g) of the given page. The content type is defined by the `type` field in front matter, or inferred from the top-level directory name if the `type` field in front matter is not defined.
With this content structure:
@@ -33,7 +33,7 @@ content/
└── _index.md
```
To list the books, regardless of [section]:
To list the books, regardless of [section](g):
```go-html-template
{{ range where .Site.RegularPages.ByTitle "Type" "books" }}
@@ -51,6 +51,4 @@ Hugo renders this to;
The `type` field in front matter is also useful for targeting a template. See&nbsp;[details].
[content type]: /getting-started/glossary/#content-type
[details]: /templates/lookup-order/#target-a-template
[section]: /getting-started/glossary/#section

View File

@@ -9,9 +9,7 @@ action:
signatures: [PAGE.Weight]
---
The `Weight` method on a `Page` object returns the [weight] of the given page as defined in front matter.
[weight]: /getting-started/glossary/#weight
The `Weight` method on a `Page` object returns the [weight](g) of the given page as defined in front matter.
{{< code-toggle file=content/recipes/sushi.md fm=true >}}
title = 'How to make spicy tuna hand rolls'

View File

@@ -2,4 +2,4 @@
_comment: Do not remove front matter.
---
A _section_ is a top-level content directory, or any content directory with an&nbsp;_index.md&nbsp;file.
A _section_ is a top-level content directory, or any content directory with an&nbsp;`_index.md`&nbsp;file.

View File

@@ -55,6 +55,6 @@ When you visit page-2:
To reverse the meaning of _next_ and _previous_ you can change the sort direction in your [site configuration], or use the [`Next`] and [`Prev`] methods on a `Pages` object for more flexibility.
[site configuration]: getting-started/configuration/#configure-page
[site configuration]: /getting-started/configuration/#configure-page
[`Next`]: /methods/pages/prev
[`Prev`]: /methods/pages/prev

View File

@@ -55,7 +55,7 @@ When you visit page-2:
To reverse the meaning of _next_ and _previous_ you can change the sort direction in your [site configuration], or use the [`Next`] and [`Prev`] methods on a `Pages` object for more flexibility.
[site configuration]: getting-started/configuration/#configure-page
[site configuration]: /getting-started/configuration/#configure-page
[`Next`]: /methods/pages/prev
[`Prev`]: /methods/pages/prev

View File

@@ -1,10 +0,0 @@
---
_comment: Do not remove front matter.
---
Hugo generates one or more files per page when building a site. For example, when rendering home, [section], [taxonomy], and [term] pages, Hugo generates an HTML file and an RSS file. Both HTML and RSS are built-in _output formats_. Create multiple output formats, and control generation based on [page kind], or by enabling one or more output formats for one or more pages. See&nbsp;[details].
[section]: /getting-started/glossary/#section
[taxonomy]: /getting-started/glossary/#taxonomy
[term]: /getting-started/glossary/#term
[page kind]: /getting-started/glossary/#page-kind
[details]: /templates/output-formats/