Putting this here in case others have run into it.
So my default archetype is:
---
title: "{{ replace .Name "-" " " }}"
date: {{ .Date }}
publishdate: {{ now.Format "2006-01-02" }}
lastmod: {{ now.Format "2006-01-02" }}
draft: true
---
Then in my single page template at layouts/_default/single.html
I have logic to show the last updated date on a post:
{{ .PublishDate.Format "January 2, 2006" }}{{ if ne .PublishDate .Lastmod }}, last updated {{ .Lastmod.Format "January 2, 2006" }}{{ end }}
This was behaving as expected in my development environment.
But when I would deploy to Netlify, the .Lastmod
date was showing the date that the file had last been edited, not the lastmod
value I had set in the post’s front matter.
After exploring the docs, I learned that the default configuration for lastmod
is to use the Git author date for the last revision of the file. But only if --enableGitInfo
is passed, or enableGitInfo = true
is set in site config.
Turns out, I had HUGO_ENABLEGITINFO = "true"
set in my netlify.toml
file.
After spending an hour tracking this down, this is what I get for blindly copy/pasting my netlify.toml
file when first creating my site