mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-20 21:31:32 +02:00
Merge commit '7c62d6ef1654c0383eae474d3bd9ddf7754c1f30'
This commit is contained in:
@@ -16,52 +16,52 @@ The following is a list of page-level variables. Many of these will be defined i
|
||||
## Page variables
|
||||
|
||||
.AlternativeOutputFormats
|
||||
: contains all alternative formats for a given page; this variable is especially useful `link rel` list in your site's `<head>`. (See [Output Formats](/templates/output-formats/).)
|
||||
: Contains all alternative formats for a given page; this variable is especially useful `link rel` list in your site's `<head>`. (See [Output Formats](/templates/output-formats/).)
|
||||
|
||||
.Aliases
|
||||
: aliases of this page
|
||||
: Aliases of this page
|
||||
|
||||
.Ancestors
|
||||
: get the ancestors of each page, simplify [breadcrumb navigation](/content-management/sections#example-breadcrumb-navigation) implementation complexity
|
||||
: Get the ancestors of each page, simplify [breadcrumb navigation](/content-management/sections#example-breadcrumb-navigation) implementation complexity
|
||||
|
||||
.BundleType
|
||||
: the [bundle] type: `leaf`, `branch`, or an empty string if the page is not a bundle.
|
||||
: The [bundle] type: `leaf`, `branch`, or an empty string if the page is not a bundle.
|
||||
|
||||
.Content
|
||||
: the content itself, defined below the front matter.
|
||||
: The content itself, defined below the front matter.
|
||||
|
||||
.Data
|
||||
: the data specific to this type of page.
|
||||
: The data specific to this type of page.
|
||||
|
||||
.Date
|
||||
: the date associated with the page; `.Date` pulls from the `date` field in a content's front matter. See also `.ExpiryDate`, `.PublishDate`, and `.Lastmod`.
|
||||
: The date associated with the page. By default, this is the front matter `date` value. See [configuring dates] for a description of fallback values and precedence. See also `.ExpiryDate`, `.Lastmod`, and `.PublishDate`.
|
||||
|
||||
.Description
|
||||
: the description for the page.
|
||||
: The description for the page.
|
||||
|
||||
.Draft
|
||||
: a boolean, `true` if the content is marked as a draft in the front matter.
|
||||
: A boolean, `true` if the content is marked as a draft in the front matter.
|
||||
|
||||
.ExpiryDate
|
||||
: the date on which the content is scheduled to expire; `.ExpiryDate` pulls from the `expirydate` field in a content's front matter. See also `.PublishDate`, `.Date`, and `.Lastmod`.
|
||||
: The date on which the content is scheduled to expire. By default, this is the front matter `expiryDate` value. See [configuring dates] for a description of fallback values and precedence. See also `.Date`, `.Lastmod`, and `.PublishDate`.
|
||||
|
||||
.File
|
||||
: filesystem-related data for this content file. See also [File Variables].
|
||||
: Filesystem-related data for this content file. See also [File Variables].
|
||||
|
||||
.Fragments
|
||||
: Fragments returns the fragments for this page. See [Page Fragments](#page-fragments).
|
||||
|
||||
.FuzzyWordCount
|
||||
: the approximate number of words in the content.
|
||||
: The approximate number of words in the content.
|
||||
|
||||
.IsHome
|
||||
: `true` in the context of the [homepage](/templates/homepage/).
|
||||
|
||||
.IsNode
|
||||
: always `false` for regular content pages.
|
||||
: Always `false` for regular content pages.
|
||||
|
||||
.IsPage
|
||||
: always `true` for regular content pages.
|
||||
: Always `true` for regular content pages.
|
||||
|
||||
.IsSection
|
||||
: `true` if [`.Kind`](/templates/section-templates/#page-kinds) is `section`.
|
||||
@@ -70,24 +70,19 @@ The following is a list of page-level variables. Many of these will be defined i
|
||||
: `true` if there are translations to display.
|
||||
|
||||
.Keywords
|
||||
: the meta keywords for the content.
|
||||
: The meta keywords for the content.
|
||||
|
||||
.Kind
|
||||
: the page's *kind*. Possible return values are `page`, `home`, `section`, `taxonomy`, or `term`. Note that there are also `RSS`, `sitemap`, `robotsTXT`, and `404` kinds, but these are only available during the rendering of each of these respective page's kind and therefore *not* available in any of the `Pages` collections.
|
||||
: The page's *kind*. Possible return values are `page`, `home`, `section`, `taxonomy`, or `term`. Note that there are also `RSS`, `sitemap`, `robotsTXT`, and `404` kinds, but these are only available during the rendering of each of these respective page's kind and therefore *not* available in any of the `Pages` collections.
|
||||
|
||||
.Language
|
||||
: a language object that points to the language's definition in the site configuration. `.Language.Lang` gives you the language code.
|
||||
: A language object that points to the language's definition in the site configuration. `.Language.Lang` gives you the language code.
|
||||
|
||||
.Lastmod
|
||||
: the date the content was last modified. `.Lastmod` pulls from the `lastmod` field in a content's front matter.
|
||||
|
||||
- If `lastmod` is not set, and `.GitInfo` feature is disabled, the front matter `date` field will be used.
|
||||
- If `lastmod` is not set, and `.GitInfo` feature is enabled, `.GitInfo.AuthorDate` will be used instead.
|
||||
|
||||
See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo].
|
||||
: The date on which the content was last modified. By default, if `enableGitInfo` is `true` in your site configuration, this is the Git author date, otherwise the front matter `lastmod` value. See [configuring dates] for a description of fallback values and precedence. See also `.Date`,`ExpiryDate`, `.PublishDate`, and [`.GitInfo`][gitinfo].
|
||||
|
||||
.LinkTitle
|
||||
: access when creating links to the content. If set, Hugo will use the `linktitle` from the front matter before `title`.
|
||||
: Access when creating links to the content. If set, Hugo will use the `linktitle` from the front matter before `title`.
|
||||
|
||||
.Next
|
||||
: Points up to the next [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ with .Next }}{{ .Permalink }}{{ end }}`. Calling `.Next` from the first page returns `nil`.
|
||||
@@ -96,20 +91,19 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo].
|
||||
: Points up to the next [regular page](/variables/site/#site-pages) below the same top level section (e.g. in `/blog`)). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ with .NextInSection }}{{ .Permalink }}{{ end }}`. Calling `.NextInSection` from the first page returns `nil`.
|
||||
|
||||
.OutputFormats
|
||||
: contains all formats, including the current format, for a given page. Can be combined the with [`.Get` function](/functions/get/) to grab a specific format. (See [Output Formats](/templates/output-formats/).)
|
||||
: Contains all formats, including the current format, for a given page. Can be combined the with [`.Get` function](/functions/get/) to grab a specific format. (See [Output Formats](/templates/output-formats/).)
|
||||
|
||||
.Pages
|
||||
: a collection of associated pages. This value will be `nil` within
|
||||
the context of regular content pages. See [`.Pages`](#pages).
|
||||
: A collection of associated pages. This value will be `nil` within the context of regular content pages. See [`.Pages`](#pages).
|
||||
|
||||
.Permalink
|
||||
: the Permanent link for this page; see [Permalinks](/content-management/urls/)
|
||||
: The Permanent link for this page; see [Permalinks](/content-management/urls/)
|
||||
|
||||
.Plain
|
||||
: the Page content stripped of HTML tags and presented as a string. You may need to pipe the result through the [`htmlUnescape`](/functions/htmlunescape/) function when rendering this value with the HTML [output format](/templates/output-formats#output-format-definitions).
|
||||
: The Page content stripped of HTML tags and presented as a string. You may need to pipe the result through the [`htmlUnescape`](/functions/htmlunescape/) function when rendering this value with the HTML [output format](/templates/output-formats#output-format-definitions).
|
||||
|
||||
.PlainWords
|
||||
: the slice of strings that results from splitting .Plain into words, as defined in Go's [strings.Fields](https://pkg.go.dev/strings#Fields).
|
||||
: The slice of strings that results from splitting .Plain into words, as defined in Go's [strings.Fields](https://pkg.go.dev/strings#Fields).
|
||||
|
||||
.Prev
|
||||
: Points down to the previous [regular page](/variables/site/#site-pages) (sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath)). Example: `{{ if .Prev }}{{ .Prev.Permalink }}{{ end }}`. Calling `.Prev` from the last page returns `nil`.
|
||||
@@ -118,71 +112,71 @@ See also `.ExpiryDate`, `.Date`, `.PublishDate`, and [`.GitInfo`][gitinfo].
|
||||
: Points down to the previous [regular page](/variables/site/#site-pages) below the same top level section (e.g. `/blog`). Pages are sorted by Hugo's [default sort](/templates/lists#default-weight--date--linktitle--filepath). Example: `{{ if .PrevInSection }}{{ .PrevInSection.Permalink }}{{ end }}`. Calling `.PrevInSection` from the last page returns `nil`.
|
||||
|
||||
.PublishDate
|
||||
: the date on which the content was or will be published; `.Publishdate` pulls from the `publishdate` field in a content's front matter. See also `.ExpiryDate`, `.Date`, and `.Lastmod`.
|
||||
: The date on which the content was or will be published. By default, this is the front matter `publishDate` value. See [configuring dates] for a description of fallback values and precedence. See also `.Date`, `.ExpiryDate`, and `.Lastmod`.
|
||||
|
||||
.RawContent
|
||||
: raw markdown content without the front matter. Useful with [remarkjs.com](
|
||||
: Raw markdown content without the front matter. Useful with [remarkjs.com](
|
||||
https://remarkjs.com)
|
||||
|
||||
.ReadingTime
|
||||
: the estimated time, in minutes, it takes to read the content.
|
||||
: The estimated time, in minutes, it takes to read the content.
|
||||
|
||||
.Resources
|
||||
: resources such as images and CSS that are associated with this page
|
||||
: Resources such as images and CSS that are associated with this page
|
||||
|
||||
.Ref
|
||||
: returns the permalink for a given reference (e.g., `.Ref "sample.md"`). `.Ref` does *not* handle in-page fragments correctly. See [Cross References](/content-management/cross-references/).
|
||||
: Returns the permalink for a given reference (e.g., `.Ref "sample.md"`). `.Ref` does *not* handle in-page fragments correctly. See [Cross References](/content-management/cross-references/).
|
||||
|
||||
.RelPermalink
|
||||
: the relative permanent link for this page.
|
||||
: The relative permanent link for this page.
|
||||
|
||||
.RelRef
|
||||
: returns the relative permalink for a given reference (e.g., `RelRef
|
||||
: Returns the relative permalink for a given reference (e.g., `RelRef
|
||||
"sample.md"`). `.RelRef` does *not* handle in-page fragments correctly. See [Cross References](/content-management/cross-references/).
|
||||
|
||||
.Site
|
||||
: see [Site Variables](/variables/site/).
|
||||
: See [Site Variables](/variables/site/).
|
||||
|
||||
.Sites
|
||||
: returns all sites (languages). A typical use case would be to link back to the main language: `<a href="{{ .Sites.First.Home.RelPermalink }}">...</a>`.
|
||||
: Returns all sites (languages). A typical use case would be to link back to the main language: `<a href="{{ .Sites.First.Home.RelPermalink }}">...</a>`.
|
||||
|
||||
.Sites.First
|
||||
: returns the site for the first language. If this is not a multilingual setup, it will return itself.
|
||||
: Returns the site for the first language. If this is not a multilingual setup, it will return itself.
|
||||
|
||||
.Summary
|
||||
: a generated summary of the content for easily showing a snippet in a summary view. The breakpoint can be set manually by inserting <code><!--more--></code> at the appropriate place in the content page, or the summary can be written independent of the page text. See [Content Summaries](/content-management/summaries/) for more details.
|
||||
: A generated summary of the content for easily showing a snippet in a summary view. The breakpoint can be set manually by inserting <code><!--more--></code> at the appropriate place in the content page, or the summary can be written independent of the page text. See [Content Summaries](/content-management/summaries/) for more details.
|
||||
|
||||
.TableOfContents
|
||||
: the rendered [table of contents](/content-management/toc/) for the page.
|
||||
: The rendered [table of contents](/content-management/toc/) for the page.
|
||||
|
||||
.Title
|
||||
: the title for this page.
|
||||
: The title for this page.
|
||||
|
||||
.Translations
|
||||
: a list of translated versions of the current page. See [Multilingual Mode](/content-management/multilingual/) for more information.
|
||||
: A list of translated versions of the current page. See [Multilingual Mode](/content-management/multilingual/) for more information.
|
||||
|
||||
.TranslationKey
|
||||
: the key used to map language translations of the current page. See [Multilingual Mode](/content-management/multilingual/) for more information.
|
||||
: The key used to map language translations of the current page. See [Multilingual Mode](/content-management/multilingual/) for more information.
|
||||
|
||||
.Truncated
|
||||
: a boolean, `true` if the `.Summary` is truncated. Useful for showing a "Read more..." link only when necessary. See [Summaries](/content-management/summaries/) for more information.
|
||||
: A boolean, `true` if the `.Summary` is truncated. Useful for showing a "Read more..." link only when necessary. See [Summaries](/content-management/summaries/) for more information.
|
||||
|
||||
.Type
|
||||
: the [content type](/content-management/types/) of the content (e.g., `posts`).
|
||||
: The [content type](/content-management/types/) of the content (e.g., `posts`).
|
||||
|
||||
.Weight
|
||||
: assigned weight (in the front matter) to this content, used in sorting.
|
||||
: Assigned weight (in the front matter) to this content, used in sorting.
|
||||
|
||||
.WordCount
|
||||
: the number of words in the content.
|
||||
: The number of words in the content.
|
||||
|
||||
## Writable page-scoped variables
|
||||
|
||||
[.Scratch][scratch]
|
||||
: returns a Scratch to store and manipulate data. In contrast to the [`.Store`][store] method, this scratch is reset on server rebuilds.
|
||||
: Returns a Scratch to store and manipulate data. In contrast to the [`.Store`][store] method, this scratch is reset on server rebuilds.
|
||||
|
||||
[.Store][store]
|
||||
: returns a Scratch to store and manipulate data. In contrast to the [`.Scratch`][scratch] method, this scratch is not reset on server rebuilds.
|
||||
: Returns a Scratch to store and manipulate data. In contrast to the [`.Scratch`][scratch] method, this scratch is not reset on server rebuilds.
|
||||
|
||||
## Section variables and methods
|
||||
|
||||
@@ -247,7 +241,7 @@ For this reason, Hugo provides a global `page` function that you can use to acce
|
||||
{{ page.Title }}
|
||||
```
|
||||
|
||||
There are one caveat with this, and this isn't new, but it's worth mentioning here: There are situations in Hugo where you may see a cached value, e.g. when using `partialCached` or in a shortcode.
|
||||
There are one caveat with this, and this isn't new, but it's worth mentioning here: There are situations in Hugo where you may see a cached value, e.g. when using `partialCached` or in a shortcode.
|
||||
|
||||
## Page-level params
|
||||
|
||||
@@ -318,6 +312,7 @@ author:
|
||||
{{ $.Param "author.display_name" }}
|
||||
```
|
||||
|
||||
[configuring dates]: /getting-started/configuration/#configure-dates
|
||||
[gitinfo]: /variables/git/
|
||||
[File Variables]: /variables/files/
|
||||
[bundle]: /content-management/page-bundles
|
||||
|
Reference in New Issue
Block a user