hugo/content/en/methods/page/Lastmod.md
Bjørn Erik Pedersen 9b0050e9aa Squashed 'docs/' content from commit 5c085a37b
git-subtree-dir: docs
git-subtree-split: 5c085a37b297bf12f59efeaae591418ec025c10d
2024-01-27 10:48:33 +01:00

1.4 KiB

title description categories keywords action
Lastmod Returns the last modification date of the given page.
related returnType signatures
methods/page/Date
methods/page/ExpiryDate
methods/page/PublishDate
methods/page/GitInfo
time.Time
PAGE.Lastmod

Set the last modification date in front matter:

{{< code-toggle file=content/news/article-1.md fm=true >}} title = 'Article 1' lastmod = 2023-10-19T00:40:04-07:00 {{< /code-toggle >}}

The last modification date is a time.Time value. Format and localize the value with the time.Format function, or use it with any of the time methods.

{{ .Lastmod | time.Format ":date_medium" }} → Oct 19, 2023

In the example above we explicitly set the last modification date in front matter. With Hugo's default configuration, the Lastmod method returns the front matter value. This behavior is configurable, allowing you to:

  • Set the last modification date to the Author Date of the last Git commit for that file. See GitInfo for details.
  • Set fallback values if the last modification date is not defined in front matter.

Learn more about date configuration.