GitInfo.AuthorDate overriding lastmod frontmatter in .Lastmod variable

I’m having an issue using .Lastmod as part of my Pages. The docs on the .Lastmod Variable specify that:

If lastmod is not set, and .GitInfo feature is enabled, .GitInfo.AuthorDate will be used instead.

This seems to imply that I can specify lastmod in the frontmatter and that value will be preferred over .GitInfo.AuthorDate, but what I’m experiencing is that .GitInfo.AuthorDate is being used regardless of whether lastmod is set or not.

Printing out the 3 variables demonstrates this:

{{ printf "Lastmod: %#v" .Lastmod }}
{{ printf "Params.lastmod: %#v" .Params.lastmod }}
{{ printf "GitInfo.AuthorDate: %#v" .GitInfo.AuthorDate }}

Lastmod: time.Time{wall:0x0, ext:63657100087, loc:(*time.Location)(0x20ac180)}
Params.lastmod: time.Time{wall:0x0, ext:63656323200, loc:(*time.Location)(nil)}
GitInfo.AuthorDate: time.Time{wall:0x0, ext:63657100087, loc:(*time.Location)(0x20ac180)}

Am I misunderstanding the docs, or is this a bug?

Any help with this?

I’m facing the same issue, I have defined lastmod parameter in the front matter but it is still (for all pages) overriden by gitinfo.

The current documentation looks a little inaccurate in this area, but there is a way around it:

1 Like