Using multiple dates in front matter

So in the front matter of my blog posts, I want a user to be able to specify the date that a post is made and later be able to add an updated tag if the post gets updated later on:


date: 2018-05-09 17:54:00
updated: 2018-06-25 18:23:100

I’m able to format the date tag in the way I want but I can’t find a way to do the same with the “updated” tag:

{{ .Date.Format “2006-01-02T15:04:00Z” | safeHTML }}
{{ .Params.updated.Format “2006-01-02T15:04:00Z” | safeHTML }}

Is there an easy way to do this?

.Format works on the .PublishDate, .Date, and .Lastmod page variables. You are looking for dateFormat. Also, there are lots of threads about date format.

1 Like

Excellent, I’ve read the .Format documentation many times but didn’t even think about using lastmod. Thanks!

I recommend sticking with the built-in standard dates in Hugo: date, lastmod, publishdate, expirydate. They have meaning.

1 Like