Debian Codegraph @

docs/content/en/methods/page/Date.md

raw
1 ---
2 title: Date
3 description: Returns the date of the given page.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: time.Time
9 signatures: [PAGE.Date]
10 ---
11
12 Set the date in front matter:
13
14 {{< code-toggle file=content/news/article-1.md fm=true >}}
15 title = 'Article 1'
16 date = 2023-10-19T00:40:04-07:00
17 {{< /code-toggle >}}
18
19 > [!NOTE]
20 > The date field in front matter is often considered to be the creation date, You can change its meaning, and its effect on your project, in your project configuration. See [details][].
21
22 The 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][].
23
24 ```go-html-template
25 {{ .Date | time.Format ":date_medium" }} → Oct 19, 2023
26 ```
27
28 In the example above we explicitly set the date in front matter. With Hugo's default configuration, the `Date` method returns the front matter value. This behavior is configurable, allowing you to set fallback values if the date is not defined in front matter. See [details][].
29
30 [`time.Format`]: /functions/time/format/
31 [details]: /configuration/front-matter/#dates
32 [time methods]: /methods/time/
33 [time.Time]: https://pkg.go.dev/time#Time