hugoUpdateLastmod command
1. Help
Command: bin/hugoUpdateLastmod --help
SYNOPSIS:
Updates lastmod field in Hugo frontmatter
based on git modification date or current date.
USAGE: hugoUpdateLastmod [OPTIONS]
USAGE: hugoUpdateLastmod [--help|-h] [--config]
[--bash-framework-config <bash-framework-config>] [--verbose|-v] [-vv] [-vvv]
[--log-level <log-level>] [--log-file <log-file>]
[--display-level <display-level>] [--no-color] [--theme <theme>] [--version]
[--quiet|-q] [--init] [--commit]
GLOBAL OPTIONS:
--help, -h {single}
Displays this command help
--config {single}
Displays configuration
--bash-framework-config <bash-framework-config> {single}
Use alternate bash framework configuration.
--verbose, -v {single}
Info level verbose mode (alias of --display-level INFO)
-vv {single}
Debug level verbose mode (alias of --display-level DEBUG)
-vvv {single}
Trace level verbose mode (alias of --display-level TRACE)
--log-level <log-level> {single}
Set log level
Possible values:
- OFF
- ERR
- ERROR
- WARN
- WARNING
- INFO
- DEBUG
- TRACE
Default value: OFF
--log-file <log-file> {single}
Set log file
Default value: /bash/logs/hugoUpdateLastmod.log
--display-level <display-level> {single}
Set display level
Possible values:
- OFF
- ERR
- ERROR
- WARN
- WARNING
- INFO
- DEBUG
- TRACE
Default value: INFO
--no-color {single}
Produce monochrome output. alias of --theme noColor.
--theme <theme> {single}
Choose color theme - default-force means colors will be produced even if
command is piped.
Possible values:
- default
- default-force
- noColor
Default value: default
--version {single}
Print version information and quit.
--quiet, -q {single}
Quiet mode, doesn't display any output.
OPTIONS:
--init {single}
Run in migration mode to update all git-tracked markdown files
in content/ directory
Incompatible with the option --commit
Updates all git-tracked ".md" files in "content/" directory
- Migrates "creationDate" → "date"
- Migrates "lastUpdated" → "lastmod" - Removes old field names
- Adds "version: "1.0"" if version field doesn't exist
- Uses git history for dates if old fields don't exist
- Places "date", "lastmod", and "version" at the end of frontmatter
--commit {single}
Run in commit mode to update staged markdown files in git.
Automatically detects staged "content/**/*.md" files and updates
their frontmatter metadata.
Incompatible with the option --init
Updates specific files that are staged in git (for pre-commit hooks)
- Automatically detects staged "content/**/*.md" files
- Adds "date" if missing (current timestamp)
- Updates "lastmod" (current timestamp) with smart detection
to prevent unnecessary updates
- Increments "version" with smart detection
- Places "date", "lastmod", and "version" at the end of frontmatter
DESCRIPTION:
Update "date", "lastmod", and "version" frontmatter fields in
markdown files.
Integrates with pre-commit hooks to automatically manage Hugo
frontmatter metadata.
Two explicit modes:
1. Migration mode ("--init")
2. Commit mode ("--commit")
Smart update detection in commit mode (two complementary checks):
1. Date check: Skip if "lastmod" already has today's date
- Prevents repeated updates on multiple commits the same day
- Use case: You commit → stage changes → commit again → no update
2. Git check: Skip if file has no actual content changes
- Prevents updates when running "pre-commit run -a" on unchanged files
- Checks git diff to detect real changes vs. reformatting
CHANGELOG:
1.0: Initial version
1.1: make md files at content/ root directory to be updated as well
VERSION: 1.1
AUTHOR: [François Chastanet](https://github.com/fchastanet)
SOURCE FILE: https://github.com/fchastanet/bash-tools-framework/tree/master/src/_binaries/hugoUpdateLastmod/hugoUpdateLastmod-binary.yaml
LICENSE: MIT License
Copyright (c) 2026-now François Chastanet
2. Usage
Update lastmod field in Hugo frontmatter based on git modification dates or the current date. It can be run in two
modes: migration mode (using --init) to update all git-tracked markdown files in the content/ directory, and commit
mode (using --commit) to update only staged files. The hook includes smart update detection to prevent unnecessary
changes, making it ideal for use in pre-commit hooks to ensure that your Hugo content is always up-to-date with the
latest modification dates.