Skip to content

Add :gitauthordate and :gitcommitdate front matter config tokens #13873

@dilyanpalauzov

Description

@dilyanpalauzov

The generated sitemap.xml includes for each post a tag <lastmod>DATE-TIME</lastmod>. The included date should be the last time, when the page was modified. With enableGitInfo: true the last modification is derived from Author Date: of the commit. At https://gohugo.io/methods/page/gitinfo/ is written:

When you set enableGitInfo to true, or enable the feature with the command line flag, the last modification date for each content page will be the Author Date of the last commit for that file.

This is configurable. See https://gohugo.io/configuration/front-matter/#dates .

My reading of "This is configurable" means that I can use CommitDate instead of AuthorDate. But I cannot out of the box do so.

When I modify a commit with an article several times, the AuthorDate of the commit does not change, the CommitDate changes. The implication is that with enableGitInfo the generated site may contains under <lastmod> wrong information: AuthorDate instead of CommitDate and thus not the last modification.

  • Provided that CommitDate cannot be before AuthorDate, when generating sitemaps with enableGitInfo: true the date in <lastmod> must be from CommitDate.

Disadvantage of this suggestion: with git-rebase CommitDate changes, while the article and AuthorDate does not change. However this is insigificant: too-new last-modification in the sitemap will cause recrawling the web page by search engines. While too-old last-modification in the sitemap file will skip recrawling of updated content.

hugo v0.148.0-DEV-1e9a0b93e3e5e1e0d25d4b8d8c36d5a2d7656f66+extended linux/amd64 BuildDate=2025-07-03T08:46:37Z

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions