Debian Codegraph @

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

raw
1 ---
2 title: PublishDate
3 description: Returns the publish date of the given page.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: time.Time
9 signatures: [PAGE.PublishDate]
10 ---
11
12 By default, Hugo excludes pages with future publish dates when building your project. To include future pages, use the `--buildFuture` command line flag.
13
14 Set the publish date in front matter:
15
16 {{< code-toggle file=content/news/article-1.md fm=true >}}
17 title = 'Article 1'
18 publishDate = 2023-10-19T00:40:04-07:00
19 {{< /code-toggle >}}
20
21 The publish 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][].
22
23 ```go-html-template
24 {{ .PublishDate | time.Format ":date_medium" }} → Oct 19, 2023
25 ```
26
27 In the example above we explicitly set the publish date in front matter. With Hugo's default configuration, the `PublishDate` method returns the front matter value. This behavior is configurable, allowing you to set fallback values if the publish date is not defined in front matter. See [details][].
28
29 [`time.Format`]: /functions/time/format/
30 [details]: /configuration/front-matter/#dates
31 [time methods]: /methods/time/
32 [time.Time]: https://pkg.go.dev/time#Time