Clarify front matter date fields

This commit is contained in:
Joe Mooring authored and GitHub committed 2023-08-06 17:19:35 -07:00
1 parent 69df4fc228
commit a7e1e9be85
1 file changed
+47 -52
+47 -52
View File
@@ -16,52 +16,52 @@ The following is a list of page-level variables. Many of these will be defined i
## Page variables ## Page variables
.AlternativeOutputFormats .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
: aliases of this page : Aliases of this page
.Ancestors .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 .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 .Content
: the content itself, defined below the front matter. : The content itself, defined below the front matter.
.Data .Data
: the data specific to this type of page. : The data specific to this type of page.
.Date .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 .Description
: the description for the page. : The description for the page.
.Draft .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 .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 .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
: Fragments returns the fragments for this page. See [Page Fragments](#page-fragments). : Fragments returns the fragments for this page. See [Page Fragments](#page-fragments).
.FuzzyWordCount .FuzzyWordCount
: the approximate number of words in the content. : The approximate number of words in the content.
.IsHome .IsHome
: `true` in the context of the [homepage](/templates/homepage/). : `true` in the context of the [homepage](/templates/homepage/).
.IsNode .IsNode
: always `false` for regular content pages. : Always `false` for regular content pages.
.IsPage .IsPage
: always `true` for regular content pages. : Always `true` for regular content pages.
.IsSection .IsSection
: `true` if [`.Kind`](/templates/section-templates/#page-kinds) is `section`. : `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. : `true` if there are translations to display.
.Keywords .Keywords
: the meta keywords for the content. : The meta keywords for the content.
.Kind .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 .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 .Lastmod
: the date the content was last modified. `.Lastmod` pulls from the `lastmod` field in a content's front matter. : 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].
- 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].
.LinkTitle .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 .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`. : 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`. : 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 .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 .Pages
: a collection of associated pages. This value will be `nil` within : A collection of associated pages. This value will be `nil` within the context of regular content pages. See [`.Pages`](#pages).
the context of regular content pages. See [`.Pages`](#pages).
.Permalink .Permalink
: the Permanent link for this page; see [Permalinks](/content-management/urls/) : The Permanent link for this page; see [Permalinks](/content-management/urls/)
.Plain .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 .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 .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`. : 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`. : 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 .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 .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) https://remarkjs.com)
.ReadingTime .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
: 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 .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 .RelPermalink
: the relative permanent link for this page. : The relative permanent link for this page.
.RelRef .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/). "sample.md"`). `.RelRef` does *not* handle in-page fragments correctly. See [Cross References](/content-management/cross-references/).
.Site .Site
: see [Site Variables](/variables/site/). : See [Site Variables](/variables/site/).
.Sites .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 .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 .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>&lt;!&#x2d;&#x2d;more&#x2d;&#x2d;&gt;</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>&lt;!&#x2d;&#x2d;more&#x2d;&#x2d;&gt;</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 .TableOfContents
: the rendered [table of contents](/content-management/toc/) for the page. : The rendered [table of contents](/content-management/toc/) for the page.
.Title .Title
: the title for this page. : The title for this page.
.Translations .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 .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 .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 .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 .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 .WordCount
: the number of words in the content. : The number of words in the content.
## Writable page-scoped variables ## Writable page-scoped variables
[.Scratch][scratch] [.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] [.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 ## 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 }} {{ 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 ## Page-level params
@@ -318,6 +312,7 @@ author:
{{ $.Param "author.display_name" }} {{ $.Param "author.display_name" }}
``` ```
[configuring dates]: /getting-started/configuration/#configure-dates
[gitinfo]: /variables/git/ [gitinfo]: /variables/git/
[File Variables]: /variables/files/ [File Variables]: /variables/files/
[bundle]: /content-management/page-bundles [bundle]: /content-management/page-bundles