jmopines/site/content/config/git-dates.md
Jean-Michel Tremblay b2727be8ce Initial commit: Hugo site with Terminal theme
Scripts: setup.sh, build.sh, serve.sh (Docker-based)
Content: about, config, software, posts sections
Custom: CSS overrides, HTML sitemap layout, extended_head partial
Theme: hugo-theme-terminal via Hugo modules (go.mod)
2026-04-03 16:30:38 -04:00

929 B

title date draft tags
Automatic Dating with Git 2026-04-02 false
hugo
git
workflow

Hugo can pull dates from Git history so you never have to update lastmod by hand.

Enable Git info

# hugo.toml
enableGitInfo = true

Configure front matter date resolution

[frontmatter]
  date = [':filename', ':default']
  publishDate = [':filename', ':default']
  lastmod = [':git', ':fileModTime']

How it works

  • .Date — tries the filename first (2026-04-03-post.md), then the date field in front matter.
  • .Lastmod — uses the Git author date of the last commit that touched the file, falling back to filesystem mtime.
  • .PublishDate — same resolution chain as .Date.

Filename date formats

Hugo recognizes these patterns:

2026-04-03-my-post.md       → date: 2026-04-03, slug: my-post
2026-04-03T14-30-00-post.md → date: 2026-04-03T14:30:00