blob: 643eddc5e2de33ffd934028c9d039971e5e57c08 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
---
title: Lastmod
description: Returns the last modification date of the given page.
categories: []
keywords: []
params:
functions_and_methods:
returnType: time.Time
signatures: [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].
```go-html-template
{{ .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].
[`gitinfo`]: /methods/page/gitinfo/
[`time.format`]: /functions/time/format/
[date configuration]: /configuration/front-matter/#dates
[time methods]: /methods/time/
[time.time]: https://pkg.go.dev/time#Time
|