Just Curious: Why does the lastmod default hierarchy put date before publishDate?

As stated in title:

Why does the “lastmod” date default value hierarchy put “date” before “publishDate”?

See: Lastmod hierarchy in docs

I would have thought a more natural order would reversed those two.

No biggy - just curious about the rationale.

date is the date set in frontmatter.

If you don’t like this, change it in your config file.
My settings:

date                       = [ "date", ":filename", ":default"]
publishDate                = [ "publishDate", "date"]
lastmod                    = [ "lastmod", ":fileModTime", "publishDate"]

That is non-obvious to me. Why do you think that?

So if:

  1. the “date” value represents the document’s creation date; and
  2. “publishDate” represents the date the document is published,

then “publishDate” (publish) must be either equal to or after “date” (creation) - certainly it can’t predate it.

So when looking to fulfil “lastmod” (when document was last modified), it is illogical to first check for a creation date before checking for a publish date - it results in error where the publish date is different from the creation date.

It should first check to see if a date was supplied for the publish date and then, if none were provided, check to see if a date was provided for the creation date.

Have I perhaps misunderstood the semantic value of “date”?

I create documents that have a date, as they are text files that I just made. But sometimes the content is from the past, and was published before I made the text file, and so have a publishDate predating the date.

Oh, that sounds serious. What is the error? We should probably fix it so it doesn’t break out of the box. :slight_smile:

My understanding is from the summaries at Front Matter | Hugo


the datetime at which the content was created; note this value is auto-populated according to Hugo’s built-in archetype.


if in the future, content will not be rendered unless the --buildFuture flag is passed to hugo .

the datetime at which the content was last modified.

Going by those definitions, and in the absence of another explanation, then I’ll assume the order is wrong.

More to the point, here is an example of common and expected use case where an error would result:

  1. A post is created on 1 Dec 2020;
  2. The publish date is set as 25 December 2020;
  3. After 25 December 2020 and when the post is published and as a page live on the site:
    3.1 the sitemap will incorrectly list the url’s lastmod date as 1 December 2020 (absent one of the other dates); and
    3.2 if the post contains a conditional lastmod field in the template for “Post Last Updated”, then that will also incorrectly list 1 December 2020.

Note that “publishDate”'s definition very clearly contemplates it being used in this way with the future flag - not the way you are using it.

As to your particular use case you’ve cited in support of the opposite, I would say it would be more consistent with Hugo’s contemplated date system to overwrite “date” with the earlier creation date as “date”, and ten set “publishDate” as the date you publish it.

At the end of the day, it can be correct by setting the order in config anyway.

You’ve got a lot going on there, so I’ll just say: I was responding to “certainly it can’t predate it” portion. I wasn’t arguing or describing how it works. Good luck. :slight_smile:

No it isn’t. It works as intented.

But this is subjecitve, which is why we added the configuration option.

1 Like

Returning to my original question, can someone explain why it looks at the creation date before the publish date?

I want to know so I can understand it.

There is no “creation date” in Hugo.

So I think my queries have been mistaken as “attacks” - which is not how I meant them to come across. I genuinely don’t understand the rationale for the order.

That said, I’ll drop it and just change it in my configuration for my case.

Otherwise, let me say thank you @bep and @maiki for doing a great job maintaining the project and contributing on the forum - keep up the good work.

I agree with @Tim_Bradley that

  lastmod = [":git", "lastmod", "date", "publishDate"]

seems weird, especially since Front Matter | Hugo says:


the datetime at which the content was created; note this value is auto-populated according to Hugo’s built-in archetype.

Maybe the Front Matter documentation page could be updated so it says something like this:


One of the datetimes associated with the page. Its main use is for sorting pages, for example, in lists and Next/Previous navigation. See also expiryDate, lastmod, and publishDate. It used to be a required front-matter variable, but as of Hugo v??? it no longer needs to be specified in a page’s front matter.

1 Like
1 Like