`.Params.date` is no longer null when not specified

In Hugo 0.34, if a page didn’t specify date in its frontmatter, .Params.date would be nil, which is great for checking if content has a date, and so not showing one. In Hugo >0.35, .Params.date is always set to something, even if it’s the base date (0 in unix epoch), which is truethy, and so shows a date on a lot of content which doesn’t specify one.

I’m fairly sure I’ve found the issue: https://github.com/gohugoio/hugo/blob/34ba97ce86f30552db40e06b36451c7a801fe149/hugolib/page.go#L1357.Sets. (https://github.com/gohugoio/hugo/pull/4322) No matter what frontmatter was specified, date is injected into the frontmatter with a valid date. I’m not exactly sure what the right solution is.

Working out which dates to show in a logical manner is very difficult. If no date is specified, no date (or related fields) should be set, unless useModTimeAsFallback is set in config. To me, I think the right solution here is to not mutate the frontmatter, leave that as-is, defined or otherwise, and just edit .Date. However, i’m not sure if the same should go for the other date keys (lastmod etc)?

I think I have the knowledge to make the desired changes, but opening up here to get other’s opinions before I make the changes.

I would suggest you

  1. Use the Date on page as the truth about date or not.
  2. That date can never be nil, but you can do if not .Date.IsZero