Date
Syntax
PAGE.Date
Returns
time.Time
Set the date in front matter:
content/news/article-1.md
---
date: 2023-10-19T00:40:04-07:00
title: Article 1
---
+++
date = 2023-10-19T00:40:04-07:00
title = 'Article 1'
+++
{
"date": "2023-10-19T00:40:04-07:00",
"title": "Article 1"
}
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.
{{ .Date | time.Format ":date_medium" }} → Oct 19, 2023
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.