Add date-test page (created March 1)

Edit date-test page (modified April 3)

script to create new page, build in date, and fetch update date from git
This commit is contained in:
Jean-Michel Tremblay 2026-03-01 10:00:00 -05:00
parent 9a9de04e04
commit 8ec3295123
5 changed files with 60 additions and 10 deletions

16
AGENTS.md Normal file
View file

@ -0,0 +1,16 @@
# AI Agent Instructions for gohugo
## Tagging AI-Involved Content
When creating or editing Hugo content files under `site/content/`, apply the following tags in the frontmatter:
- **`AI-gen`** — Add this tag when the article was mostly written by AI (i.e., the majority of the text was generated by an AI agent).
- **`AI-reviewed`** — Add this tag when the article was reviewed, edited, or refined by AI but the original content was primarily human-written.
These tags go in the `tags` array in the TOML frontmatter. For example:
```toml
tags = ['some-topic', 'AI-gen']
```
If both apply, include both tags.

19
scripts/new.sh Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
# Create a new content page using Hugo's archetype.
# Usage: ./scripts/new.sh <path>
# Example: ./scripts/new.sh content/thissite/my-page.md
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../.env"
if [[ $# -lt 1 ]]; then
echo "Usage: $0 <content-path>"
echo "Example: $0 content/thissite/my-page.md"
exit 1
fi
docker run --rm \
-v "${SITE_DIR}:/src" \
-w /src \
"${HUGO_IMAGE}" new "$1"

View file

@ -0,0 +1,12 @@
+++
date = '2026-03-01T10:00:00Z'
draft = false
title = 'Date Test'
tags = ['test', 'AI-gen']
+++
This page was created on March 1, 2026. If the dates are working
correctly, you should see a different "Updated" date — the date
of the most recent git commit that touched this file.
(Edited on April 3 to verify the updated date changes.)

View file

@ -2,21 +2,23 @@
title: "How Dates Work on This Site"
date: 2026-04-03
draft: false
tags: ['hugo', 'git', 'workflow']
tags: ['hugo', 'git', 'workflow', 'AI-gen']
---
Every page on this site has two dates: **Created** and **Last Modified**.
Every page on this site has two dates: **Created** and **Updated**.
Neither one is maintained by hand. Here's the full flow.
## Creating a new page
New content is created via Hugo's CLI (running in Docker):
New content is created with the `new.sh` script:
```bash
docker run --rm -v "${SITE_DIR}:/src" -w /src \
ghcr.io/gohugoio/hugo:latest new content/thissite/my-page.md
./scripts/new.sh content/thissite/my-page.md
```
This sources `.env` for `HUGO_IMAGE` and `SITE_DIR`, then runs
`hugo new` inside the Docker container.
Hugo reads the archetype template at `archetypes/default.md`:
```yaml
@ -44,7 +46,7 @@ tags: []
**That `date` value is baked into the file once and never changes.**
It represents when the page was created. Nobody edits it afterward.
## How "Last Modified" works
## How "Updated" works
The `lastmod` field is **not** stored in the file at all. It's resolved
at build time by Hugo based on this config in `hugo.toml`:
@ -72,7 +74,7 @@ then render it with `{{ .Lastmod }}`.
## What does git actually track?
Git records the **author date** on each commit. When you edit a file and
commit it, that commit's date becomes the new `lastmod` for that file.
commit it, that commit's date becomes the new updated date for that file.
The original `date` in front matter is untouched — it still reflects
creation time.
@ -84,7 +86,7 @@ Date: Thu Apr 3 14:30:00 2026 -0400
Fix typo in dates page
```
Hugo will see `Apr 3 14:30:00 2026` as the `lastmod` for any file
Hugo will see `Apr 3 14:30:00 2026` as the updated date for any file
modified in that commit.
## The full lifecycle
@ -101,8 +103,8 @@ modified in that commit.
- **Created date**: set once by the archetype, stored in front matter,
never changes.
- **Last modified**: not stored in the file. Resolved from git at build
- **Updated date**: not stored in the file. Resolved from git at build
time. Zero maintenance.
- **`enableGitInfo = true`** is required in `hugo.toml` for any of the
git-based date resolution to work.
- **No tracking needed** for `lastmod` — it's derived, not stored.
- **No tracking needed** for the updated date — it's derived, not stored.

View file

@ -14,6 +14,7 @@ enableGitInfo = true
[params]
contentTypeName = "posts"
showMenuItems = 5
showLastUpdated = true
fullWidthTheme = false
centerTheme = true