I moved my blog articles to my personal website. For an unknown reason, when I run locally my website (and open it in the browser), the date in "Last updated on..." is correct, i.e it is the date
argument I put in the YAML.
However, when I push this to GitHub and deploy it through Netlify, all the articles have the mention "Last updated on Sep 22, 2020" (i.e today at the time of writing). Adding the lastmod
argument in the YAML has no influence on this.
Any idea why and how to fix it?
That is, because the 'Last updated on' date is taken from your Git commit.
You can configure which dates are taken by adding a frontmatter
section to your config.toml
.
The default is:
[frontmatter]
date = ["date", "publishDate", "lastmod"]
lastmod = [":git", "lastmod", "date", "publishDate"]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]
Which means, if available, the git commit date is taken. Running locally you don't have it, so it would take the lastmod
setting. If you don't set lastmod
locally it takes the date
.
I think it should be enough if you add this section to your config.toml
and change the order.
E.g.
[frontmatter]
date = ["date", "publishDate", "lastmod"]
lastmod = ["lastmod", "date", ":git", "publishDate"]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]
Here is more information about the topic from the official documentation: https://gohugo.io/getting-started/configuration/#configure-dates