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.
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:
[frontmatter]
date = [ "date", ":filename", ":default"]
publishDate = [ "publishDate", "date"]
lastmod = [ "lastmod", ":fileModTime", "publishDate"]
That is non-obvious to me. Why do you think that?
So if:
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. ![]()
My understanding is from the summaries at Front matter | Hugo
date
the datetime at which the content was created; note this value is auto-populated according to Hugo’s built-in archetype.
publishDate
if in the future, content will not be rendered unless the
--buildFutureflag is passed tohugo.
lastmod
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:
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. ![]()
No it isn’t. It works as intented.
But this is subjecitve, which is why we added the configuration option.
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:
date
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:
date
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.