Hugo offers a few date page variables:
Date
- the date associated with the pagePublishDate
- the date on which the content was or will be publishedLastMod
- the date the content was last modifiedExpiryDate
- the date on which the content is scheduled to expireLastMod
and ExpiryDate
make sense to me, but I am puzzled as to the difference between Date
and PublishDate
.
What are some examples of when Date
and PublishDate
are different?
If...
date
and publishDate
(see below), date
is different from publishDate
Then...
publishDate
is used to determine if a page is in the future (i.e. if hugo's -F
or --buildFuture
flag is required for the page to be built)date
is used to order pages in the default ordering (Weight > Date > LinkTitle > Title > FilePath).[*] The default order is used in next/previous navigation and can be used in a range
.Configuring dates is discussed in https://gohugo.io/getting-started/configuration/#configure-front-matter. Here is the default for date
and publishDate
:
frontmatter:
date:
- date
- publishDate
- lastmod
publishDate:
- publishDate
- date
Because I want date
and publishDate
to mean the same thing, I have the following in my config.yaml
:
frontmatter:
date:
- publishDate
- :filename
- date
- :fileModTime
publishDate:
- publishDate
- :filename
- date
- :fileModTime
I've made them the same because I, too, was puzzled by their difference!
[*] Info about ordering content in Hugo is at https://gohugo.io/templates/lists/#order-content
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With