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

@@ -54,7 +54,6 @@ In almost also scenarios you should use the [`URL`] method instead.
[`URL`]: /methods/menu-entry/url/
{{% /note %}}
Consider this content structure:
```text
@@ -99,7 +98,6 @@ In the above note that the `href` attribute of the second `anchor` element is bl
With this template code:
{{< code file=layouts/partials/menu.html >}}
<ul>
{{ range .Site.Menus.main }}

View File

@@ -32,7 +32,6 @@ weight = 30
With this template:
```go-html-template
<ul>
{{ range .Site.Menus.main }}

View File

@@ -11,7 +11,6 @@ action:
For menu entries associated with a page, the `URL` method returns the page's [`RelPermalink`], otherwise it returns the entry's `url` property.
```go-html-template
<ul>
{{ range .Site.Menus.main }}

View File

@@ -9,9 +9,7 @@ action:
signatures: [MENU.ByWeight]
---
The `ByWeight` method returns the given menu with its entries sorted by [`weight`], then by `name`, then by `identifier`. This is the default sort order.
[`weight`]: /getting-started/glossary/#weight
The `ByWeight` method returns the given menu with its entries sorted by [`weight`](g), then by `name`, then by `identifier`. This is the default sort order.
Consider this menu definition:

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&nbsp;[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&nbsp;[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&nbsp;[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/

View File

@@ -9,9 +9,7 @@ action:
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
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.
```go-html-template
{{ range .Pages.ByWeight }}

View File

@@ -15,11 +15,10 @@ action:
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.
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.
[`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" %}}

View File

@@ -15,11 +15,10 @@ action:
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.
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.
[`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" %}}

View File

@@ -15,11 +15,10 @@ action:
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.
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.
[`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" %}}

View File

@@ -13,11 +13,10 @@ action:
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.
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.
[`time.Format`]: /functions/time/format/
[layout string]: #layout-string
[localized]: /getting-started/glossary/#localization
{{% include "methods/pages/_common/group-sort-order.md" %}}

View File

@@ -15,11 +15,10 @@ action:
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.
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.
[`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" %}}

View File

@@ -45,7 +45,6 @@ To pass an options map:
{{ end }}
{{< /code >}}
## Options
indices
@@ -60,7 +59,7 @@ namedSlices
[`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.
: (`slice`) A list of special keywords that is used for indices configured as type "fragments". This will match the [fragment](g) identifiers of the documents.
A contrived example using all of the above:
@@ -75,5 +74,4 @@ A contrived example using all of the above:
```
[details]: /content-management/related/
[fragment]: /getting-started/glossary/#fragment
[related content configuration]: /content-management/related/

View File

@@ -169,7 +169,6 @@ Calculate the contrast ratio to determine WCAG conformance:
{{ end }}
```
[WCAG]: https://en.wikipedia.org/wiki/Web_Content_Accessibility_Guidelines
[contrast ratio]: https://www.w3.org/TR/WCAG21/#dfn-contrast-ratio
[enhanced]: https://www.w3.org/WAI/WCAG22/quickref/?showtechniques=145#contrast-enhanced

View File

@@ -17,10 +17,10 @@ The `Data` method on a resource returned by the [`resources.GetRemote`] function
```go-html-template
{{ $url := "https://example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
{{ with try (resources.GetRemote $url) }}
{{ with .Err }}
{{ errorf "%s" . }}
{{ else }}
{{ else with .Value }}
{{ with .Data }}
{{ .ContentLength }} → 42764
{{ .ContentType }} → image/jpeg
@@ -28,9 +28,9 @@ The `Data` method on a resource returned by the [`resources.GetRemote`] function
{{ .StatusCode }} → 200
{{ .TransferEncoding }} → []
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
{{ else }}
{{ errorf "Unable to get remote resource %q" $url }}
{{ end }}
```
@@ -49,5 +49,4 @@ StatusCode
TransferEncoding
: (`string`) The transfer encoding.
[`resources.GetRemote`]: /functions/resources/getremote/

View File

@@ -9,8 +9,15 @@ action:
- methods/resource/Data
returnType: resource.resourceError
signatures: [RESOURCE.Err]
expiryDate: 2026-01-16 # deprecated 2025-01-16
---
{{% deprecated-in 0.141.0 %}}
Use the `try` statement instead. See [example].
[example]: /functions/go-template/try/#example
{{% /deprecated-in %}}
The `Err` method on a resource returned by the [`resources.GetRemote`] function returns an error message if the HTTP request fails, else nil. If you do not handle the error yourself, Hugo will fail the build.
[`resources.GetRemote`]: /functions/resources/getremote/

View File

@@ -38,7 +38,6 @@ We used the [`resources.Copy`] function to change the publishing path. The `Key`
The `Key` method is useful if you need to get the resource's publishing path without publishing the resource. Unlike the `Permalink`, `RelPermalink`, or `Publish` methods, calling `Key` will not publish the resource.
{{% include "methods/resource/_common/global-page-remote-resources.md" %}}
[`Permalink`]: /methods/resource/permalink/

View File

@@ -15,7 +15,7 @@ The value returned by the `Name` method on a `Resource` object depends on the re
## Global resource
With a [global resource], the `Name` method returns the path to the resource, relative to the assets directory.
With a [global resource](g), the `Name` method returns the path to the resource, relative to the `assets` directory.
```text
assets/
@@ -31,7 +31,7 @@ assets/
## Page resource
With a [page resource], if you create an element in the `resources` array in front matter, the `Name` method returns the value of the `name` parameter.
With a [page resource](g), if you create an element in the `resources` array in front matter, the `Name` method returns the value of the `name` parameter.
```text
content/
@@ -81,15 +81,10 @@ content/
```
## Remote resource
With a [remote resource], the `Name` method returns a hashed file name.
With a [remote resource](g), the `Name` method returns a hashed file name.
```go-html-template
{{ with resources.GetRemote "https://example.org/images/a.jpg" }}
{{ .Name }} → /a_18432433023265451104.jpg
{{ end }}
```
[global resource]: /getting-started/glossary/#global-resource
[logical path]: /getting-started/glossary/#logical-path
[page resource]: /getting-started/glossary/#page-resource
[remote resource]: /getting-started/glossary/#remote-resource

View File

@@ -9,11 +9,7 @@ action:
signatures: [RESOURCE.Params]
---
Use the `Params` method with [page resources]. It is not applicable to either [global] or [remote] resources.
[global]: /getting-started/glossary/#global-resource
[page resources]: /getting-started/glossary/#page-resource
[remote]: /getting-started/glossary/#remote-resource
Use the `Params` method with [page resources](g). It is not applicable to either [global resources](g) or [remote resources](g).
With this content structure:

View File

@@ -11,9 +11,7 @@ action:
signatures: [RESOURCE.Permalink]
---
The `Permalink` method on a `Resource` object writes the resource to the publish directory, typically `public`, and returns its [permalink].
[permalink]: /getting-started/glossary/#permalink
The `Permalink` method on a `Resource` object writes the resource to the publish directory, typically `public`, and returns its [permalink](g).
```go-html-template
{{ with resources.Get "images/a.jpg" }}

View File

@@ -11,9 +11,7 @@ action:
signatures: [RESOURCE.RelPermalink]
---
The `Permalink` method on a `Resource` object writes the resource to the publish directory, typically `public`, and returns its [relative permalink].
[relative permalink]: /getting-started/glossary/#relative-permalink
The `Permalink` method on a `Resource` object writes the resource to the publish directory, typically `public`, and returns its [relative permalink](g).
```go-html-template
{{ with resources.Get "images/a.jpg" }}

View File

@@ -15,7 +15,7 @@ The value returned by the `Title` method on a `Resource` object depends on the r
## Global resource
With a [global resource], the `Title` method returns the path to the resource, relative to the assets directory.
With a [global resource](g), the `Title` method returns the path to the resource, relative to the `assets` directory.
```text
assets/
@@ -31,7 +31,7 @@ assets/
## Page resource
With a [page resource], if you create an element in the `resources` array in front matter, the `Title` method returns the value of the `title` parameter.
With a [page resource](g), if you create an element in the `resources` array in front matter, the `Title` method returns the value of the `title` parameter.
```text
content/
@@ -74,14 +74,10 @@ content/
## Remote resource
With a [remote resource], the `Title` method returns a hashed file name.
With a [remote resource](g), the `Title` method returns a hashed file name.
```go-html-template
{{ with resources.GetRemote "https://example.org/images/a.jpg" }}
{{ .Title }} → /a_18432433023265451104.jpg
{{ end }}
```
[global resource]: /getting-started/glossary/#global-resource
[page resource]: /getting-started/glossary/#page-resource
[remote resource]: /getting-started/glossary/#remote-resource

View File

@@ -3,11 +3,5 @@ _comment: Do not remove front matter.
---
{{% note %}}
Use this method with [global], [page], or [remote] resources.
[global]: /getting-started/glossary/#global-resource
[page]: /getting-started/glossary/#page-resource
[remote]: /getting-started/glossary/#remote-resource
Use this method with [global resources](g), [page resources](g), or [remote resources](g).
{{% /note %}}

View File

@@ -56,7 +56,6 @@ Content between opening and closing shortcode tags may include leading and/or tr
In the example above, the value returned by `Inner` is Markdown, but it was rendered as plain text. Use either of the following approaches to render Markdown to HTML.
{{% /note %}}
## Use RenderString
Let's modify the example above to pass the value returned by `Inner` through the [`RenderString`] method on the `Page` object:

View File

@@ -46,5 +46,5 @@ Welcome. Today is {{</* now */>}}.
The "now" shortcode formats the current time using:
1. The `dateFormat` argument passed to the "now" shortcode, if present
2. The `dateFormat` argument passed to the "greeting" shortcode, if present
3. The default layout string defined at the top of the shortcode
1. The `dateFormat` argument passed to the "greeting" shortcode, if present
1. The default layout string defined at the top of the shortcode

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

@@ -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

@@ -8,6 +8,7 @@ action:
- functions/collections/NewScratch
returnType: maps.Scratch
signatures: [SHORTCODE.Scratch]
expiryDate: 2025-11-18 # deprecated 2024-11-18
---
{{% deprecated-in 0.139.0 %}}
@@ -20,7 +21,7 @@ Beginning with v0.139.0 the `SHORTCODE.Scratch` method is aliased to `SHORTCODE.
[`SHORTCODE.Store`]: /methods/shortcode/store/
{{% /deprecated-in %}}
The `Scratch` method within a shortcode creates a [scratch pad] to store and manipulate data. The scratch pad is scoped to the shortcode.
The `Scratch` method within a shortcode creates a [scratch pad](g) to store and manipulate data. The scratch pad is scoped to the shortcode.
{{% note %}}
With the introduction of the [`newScratch`] function, and the ability to [assign values to template variables] after initialization, the `Scratch` method within a shortcode is obsolete.
@@ -29,6 +30,4 @@ With the introduction of the [`newScratch`] function, and the ability to [assign
[`newScratch`]: /functions/collections/newscratch/
{{% /note %}}
[scratch pad]: /getting-started/glossary/#scratch-pad
{{% include "methods/page/_common/scratch-methods.md" %}}

View File

@@ -15,7 +15,7 @@ action:
{{< new-in 0.139.0 >}}
The `Store` method within a shortcode creates a [scratch pad] to store and manipulate data. The scratch pad is scoped to the shortcode.
The `Store` method within a shortcode creates a [scratch pad](g) to store and manipulate data. The scratch pad is scoped to the shortcode.
{{% note %}}
With the introduction of the [`newScratch`] function, and the ability to [assign values to template variables] after initialization, the `Store` method within a shortcode is mostly obsolete.
@@ -24,6 +24,4 @@ With the introduction of the [`newScratch`] function, and the ability to [assign
[`newScratch`]: /functions/collections/newScratch/
{{% /note %}}
[Store pad]: /getting-started/glossary/#scratch-pad
{{% include "methods/page/_common/scratch-methods.md" %}}

View File

@@ -12,12 +12,11 @@ action:
signatures: [SITE.AllPages]
---
This method returns all page [kinds] in all languages. That includes the home page, section pages, taxonomy pages, term pages, and regular pages.
This method returns all page [kinds](g) in all languages. That includes the home page, section pages, taxonomy pages, term pages, and regular pages.
In most cases you should use the [`RegularPages`] method instead.
[`RegularPages`]: /methods/site/regularpages/
[kinds]: /getting-started/glossary/#page-kind
```go-html-template
{{ range .Site.AllPages }}

View File

@@ -13,17 +13,17 @@ action:
signatures: [SITE.Data]
---
Use the `Data` method on a `Site` object to access data within the data directory, or within any directory [mounted] to the data directory. Supported data formats include JSON, TOML, YAML, and XML.
Use the `Data` method on a `Site` object to access data within the `data` directory, or within any directory [mounted] to the `data` directory. Supported data formats include JSON, TOML, YAML, and XML.
[mounted]: /hugo-modules/configuration/#module-configuration-mounts
{{% note %}}
Although Hugo can unmarshal CSV files with the [`transform.Unmarshal`] function, do not place CSV files in the data directory. You cannot access data within CSV files using this method.
Although Hugo can unmarshal CSV files with the [`transform.Unmarshal`] function, do not place CSV files in the `data` directory. You cannot access data within CSV files using this method.
[`transform.Unmarshal`]: /functions/transform/unmarshal/
{{% /note %}}
Consider this data directory:
Consider this `data` directory:
```text
data/
@@ -55,7 +55,7 @@ And these data files:
isbn: 978-0521280495
{{< /code >}}
Access the data by [chaining] the [identifiers]:
Access the data by [chaining](g) the [identifiers](g):
```go-html-template
{{ range $category, $books := .Site.Data.books }}
@@ -101,14 +101,10 @@ To find a fiction book by ISBN:
{{ end }}
```
In the template examples above, each of the keys is a valid [identifier]. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the [`index`] function. For example:
[identifier]: /getting-started/glossary/#identifier
In the template examples above, each of the keys is a valid identifier. For example, none of the keys contains a hyphen. To access a key that is not a valid identifier, use the [`index`] function. For example:
```go-html-template
{{ index .Site.Data.books "historical-fiction" }}
```
[`index`]: /functions/collections/indexfunction/
[chaining]: /getting-started/glossary/#chain
[identifiers]: /getting-started/glossary/#identifier

View File

@@ -15,7 +15,7 @@ The `GetPage` method is also available on `Page` objects, allowing you to specif
[details]: /methods/page/getpage/
When using the `GetPage` method on a `Site` object, specify a path relative to the content directory.
When using the `GetPage` method on a `Site` object, specify a path relative to the `content` directory.
If Hugo cannot resolve the path to a page, the method returns nil.
@@ -96,7 +96,7 @@ content/
└── _index.md
```
In the home template, use the `GetPage` method on a `Site` object to render all the images in the headless [page bundle]:
In the home template, use the `GetPage` method on a `Site` object to render all the images in the headless [page bundle](g):
```go-html-template
{{ with .Site.GetPage "/headless" }}
@@ -105,5 +105,3 @@ In the home template, use the `GetPage` method on a `Site` object to render all
{{ end }}
{{ end }}
```
[page bundle]: /getting-started/glossary/#page-bundle

View File

@@ -12,12 +12,11 @@ action:
signatures: [SITE.Pages]
---
This method returns all page [kinds] in the current language. That includes the home page, section pages, taxonomy pages, term pages, and regular pages.
This method returns all page [kinds](g) in the current language. That includes the home page, section pages, taxonomy pages, term pages, and regular pages.
In most cases you should use the [`RegularPages`] method instead.
[`RegularPages`]: /methods/site/regularpages/
[kinds]: /getting-started/glossary/#page-kind
```go-html-template
{{ range .Site.Pages }}

View File

@@ -16,7 +16,6 @@ The `Param` method on a `Site` object is a convenience method to return the valu
display_toc = true
{{< /code-toggle >}}
```go-html-template
{{ .Site.Param "display_toc" }} → true
```

View File

@@ -26,7 +26,7 @@ With this site configuration:
rfc_3339 = '2006-01-02T15:04:05-07:00'
{{< /code-toggle >}}
Access the custom parameters by [chaining] the [identifiers]:
Access the custom parameters by [chaining](g) the [identifiers](g):
```go-html-template
{{ .Site.Params.subtitle }} → The Best Widgets on Earth
@@ -43,5 +43,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

@@ -12,9 +12,7 @@ action:
signatures: [SITE.RegularPages]
---
The `RegularPages` method on a `Site` object returns a collection of all [regular pages].
[regular pages]: /getting-started/glossary/#regular-page
The `RegularPages` method on a `Site` object returns a collection of all [regular pages](g).
```go-html-template
{{ range .Site.RegularPages }}

View File

@@ -16,11 +16,10 @@ toc: true
{{< new-in 0.139.0 >}}
The `Store` method on a `Site` object creates a persistent [scratch pad] to store and manipulate data. To create a locally scoped scratch pad that is not attached to a `Site` object, use the [`newScratch`] function.
The `Store` method on a `Site` 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 `Site` object, use the [`newScratch`] function.
[`Scratch`]: /methods/site/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

@@ -9,10 +9,6 @@ action:
signatures: [SITE.Taxonomies]
---
{{% comment %}}
Show template example: GetTerms
{{% /comment %}}
Conceptually, the `Taxonomies` method on a `Site` object returns a data structure such&nbsp;as:
{{< code-toggle >}}
@@ -73,7 +69,6 @@ authors:
- Pride and Prejudice
{{< /code-toggle >}}
To list the "suspense" books:
```go-html-template

View File

@@ -11,9 +11,9 @@ action:
toc: true
---
The `Alphabetical` method on a `Taxonomy` object returns an [ordered taxonomy], sorted alphabetically by [term].
The `Alphabetical` method on a `Taxonomy` object returns an [ordered taxonomy](g), sorted alphabetically by [term](g).
While a `Taxonomy` object is a [map], an ordered taxonomy is a [slice], where each element is an object that contains the term and a slice of its [weighted pages].
While a `Taxonomy` object is a [map](g), an ordered taxonomy is a [slice](g), where each element is an object that contains the term and a slice of its [weighted pages](g).
{{% include "methods/taxonomy/_common/get-a-taxonomy-object.md" %}}
@@ -69,10 +69,3 @@ Hugo renders:
<li><a href="/books/jamaica-inn/">Jamaica inn</a></li>
</ul>
```
[ordered taxonomy]: /getting-started/glossary/#ordered-taxonomy
[term]: /getting-started/glossary/#term
[map]: /getting-started/glossary/#map
[slice]: /getting-started/glossary/#slice
[term]: /getting-started/glossary/#term
[weighted pages]: /getting-started/glossary/#weighted-page

View File

@@ -11,9 +11,9 @@ action:
toc: true
---
The `ByCount` method on a `Taxonomy` object returns an [ordered taxonomy], sorted by the number of pages associated with each [term].
The `ByCount` method on a `Taxonomy` object returns an [ordered taxonomy](g), sorted by the number of pages associated with each [term](g).
While a `Taxonomy` object is a [map], an ordered taxonomy is a [slice], where each element is an object that contains the term and a slice of its [weighted pages].
While a `Taxonomy` object is a [map](g), an ordered taxonomy is a [slice](g), where each element is an object that contains the term and a slice of its [weighted pages](g).
{{% include "methods/taxonomy/_common/get-a-taxonomy-object.md" %}}
@@ -69,10 +69,3 @@ Hugo renders:
<li><a href="/books/pride-and-prejudice/">Pride and prejudice</a></li>
</ul>
```
[ordered taxonomy]: /getting-started/glossary/#ordered-taxonomy
[term]: /getting-started/glossary/#term
[map]: /getting-started/glossary/#map
[slice]: /getting-started/glossary/#slice
[term]: /getting-started/glossary/#term
[weighted pages]: /getting-started/glossary/#weighted-page

View File

@@ -10,7 +10,7 @@ action:
toc: true
---
The `Count` method on a `Taxonomy` object returns the number of number of [weighted pages] to which the given [term] has been assigned.
The `Count` method on a `Taxonomy` object returns the number of number of [weighted pages](g) to which the given [term](g) has been assigned.
{{% include "methods/taxonomy/_common/get-a-taxonomy-object.md" %}}
@@ -21,6 +21,3 @@ Now that we have captured the "genres" `Taxonomy` object, let's count the number
```go-html-template
{{ $taxonomyObject.Count "suspense" }} → 3
```
[weighted pages]: /getting-started/glossary/#weighted-page
[term]: /getting-started/glossary/#term

View File

@@ -10,7 +10,7 @@ action:
toc: true
---
The `Get` method on a `Taxonomy` object returns a slice of [weighted pages] to which the given [term] has been assigned.
The `Get` method on a `Taxonomy` object returns a slice of [weighted pages](g) to which the given [term](g) has been assigned.
{{% include "methods/taxonomy/_common/get-a-taxonomy-object.md" %}}
@@ -28,7 +28,7 @@ The above is equivalent to:
{{ $weightedPages := $taxonomyObject.suspense }}
```
But, if the term is not a valid [identifier], you cannot use the [chaining] syntax. For example, this will throw an error because the identifier contains a hyphen:
But, if the term is not a valid [identifier](g), you cannot use the [chaining](g) syntax. For example, this will throw an error because the identifier contains a hyphen:
```go-html-template
{{ $weightedPages := $taxonomyObject.my-genre }}
@@ -65,8 +65,4 @@ Hugo renders:
<h2><a href="/books/and-then-there-were-none/">And then there were none</a></h2>
```
[chaining]: /getting-started/glossary/#chain
[`index`]: /functions/collections/indexfunction/
[identifier]: /getting-started/glossary/#identifier
[term]: /getting-started/glossary/#term
[weighted pages]: /getting-started/glossary/#weighted-page

View File

@@ -59,7 +59,6 @@ Although the [`Alphabetical`] and [`ByCount`] methods provide a better data stru
In the example above, the first anchor element is a link to the term page.
[`Alphabetical`]: /methods/taxonomy/alphabetical/
[`ByCount`]: /methods/taxonomy/bycount/

View File

@@ -13,13 +13,12 @@ Page
: (`page.Page`) Returns the term's `Page` object, useful for linking to the term page.
Pages
: (`page.Pages`) Returns a `Pages` object containing the `Page` objects to which the term is assigned, sorted by [taxonomic weight]. To sort or group, use any of the [methods] available to the `Pages` object. For example, sort by the last modification date.
: (`page.Pages`) Returns a `Pages` object containing the `Page` objects to which the term is assigned, sorted by [taxonomic weight](g). To sort or group, use any of the [methods] available to the `Pages` object. For example, sort by the last modification date.
Term
: (`string`) Returns the term name.
WeightedPages
: (`page.WeightedPages`) Returns a slice of weighted pages to which the term is assigned, sorted by [taxonomic weight]. The `Pages` method above is more flexible, allowing you to sort and group.
: (`page.WeightedPages`) Returns a slice of weighted pages to which the term is assigned, sorted by taxonomic weight. The `Pages` method above is more flexible, allowing you to sort and group.
[methods]: /methods/pages/
[taxonomic weight]: /getting-started/glossary/#taxonomic-weight

View File

@@ -24,9 +24,8 @@ aliases: [/methods/time/format]
```
{{% note %}}
To [localize] the return value, use the [`time.Format`] function instead.
To [localize](g) the return value, use the [`time.Format`] function instead.
[localize]: /getting-started/glossary/#localization
[`time.Format`]: /functions/time/format/
{{% /note %}}

View File

@@ -14,7 +14,7 @@ action:
The rounding behavior for halfway values is to round up.
The `Round` method operates on TIME as an absolute duration since the [zero time]; it does not operate on the presentation form of the time. If DURATION is a multiple of one hour, `Round` may return a time with a non-zero minute, depending on the time zone.
The `Round` method operates on TIME as an absolute duration since the [zero time](g); it does not operate on the presentation form of the time. If DURATION is a multiple of one hour, `Round` may return a time with a non-zero minute, depending on the time zone.
```go-html-template
{{ $t := time.AsTime "2023-01-27T23:44:58-08:00" }}
@@ -22,5 +22,3 @@ The `Round` method operates on TIME as an absolute duration since the [zero time
{{ ($t.Round $d).Format "2006-01-02T15:04:05-00:00" }} → 2023-01-28T00:00:00-00:00
```
[zero time]: /getting-started/glossary/#zero-time

View File

@@ -12,7 +12,7 @@ action:
signatures: [TIME.Truncate DURATION]
---
The `Truncate` method operates on TIME as an absolute duration since the [zero time]; it does not operate on the presentation form of the time. If DURATION is a multiple of one hour, `Truncate` may return a time with a non-zero minute, depending on the time zone.
The `Truncate` method operates on TIME as an absolute duration since the [zero time](g); it does not operate on the presentation form of the time. If DURATION is a multiple of one hour, `Truncate` may return a time with a non-zero minute, depending on the time zone.
```go-html-template
{{ $t := time.AsTime "2023-01-27T23:44:58-08:00" }}
@@ -20,5 +20,3 @@ The `Truncate` method operates on TIME as an absolute duration since the [zero t
{{ ($t.Truncate $d).Format "2006-01-02T15:04:05-00:00" }} → 2023-01-27T23:00:00-00:00
```
[zero time]: /getting-started/glossary/#zero-time