Hugo version: hugo v0.161.1+extended+withdeploy linux/amd64
Description:
When a Hugo module's go.mod is located in a subdirectory of its git repository (rather than at the repo root), Page.GitInfo returns nil for all content from that module, even though the blobless clone created by the 0.157.0 fix (dfece5b) contains the correct git history.
Reproduction:
Repository structure:
henge/ ← git repo root
site/
go.mod ← module: codeberg.org/hereticles/site
content/
endeavours/
henge.md ← content file
Module imported in consuming site:
toml
[[module.imports]]
path = "codeberg.org/hereticles/henge/site"
[[module.imports.mounts]]
source = "content"
target = "content"
What happens:
Hugo creates the blobless clone correctly at ~/.cache/hugo_cache/modules/filecache/modulegitinfo/repo_<hash>/. Running git from within that clone confirms the history is present:
bash
git log -1 --format=%H -- site/content/endeavours/henge.md
# returns: daa0b2c43548c16f9fdde191e66b0269f9715293
However Page.GitInfo is nil. Adding a debug line:
go
{{ warnf "File path: %q" .Page.File.Filename }}
Shows:
WARN File path for "endeavours/henge.md": "/home/shri/.cache/hugo_cache/modules/filecache/modules/pkg/mod/codeberg.org/hereticles/henge/[email protected]/content/endeavours/henge.md"
Root cause:
The blobless clone maps the file as site/content/endeavours/henge.md (relative to the git repo root), but Hugo is looking up content/endeavours/henge.md (relative to the module root). The offset between the module root (site/) and the git repo root is not accounted for.
Workaround:
Move go.mod to the git repo root. The module path no longer includes the subdirectory, so the cache path strips correctly and the repo-relative path matches the blobless clone.
Expected behaviour:
Page.GitInfo should populate correctly regardless of where go.mod is located within the git repo. The path translation should account for the offset between the module root and the git repo root.
Related: dfece5b (the 0.157.0 fix that introduced the blobless clone mechanism), issue #5533
Hugo version:
hugo v0.161.1+extended+withdeploy linux/amd64Description:
When a Hugo module's
go.modis located in a subdirectory of its git repository (rather than at the repo root),Page.GitInforeturns nil for all content from that module, even though the blobless clone created by the 0.157.0 fix (dfece5b) contains the correct git history.Reproduction:
Repository structure:
Module imported in consuming site:
toml
What happens:
Hugo creates the blobless clone correctly at
~/.cache/hugo_cache/modules/filecache/modulegitinfo/repo_<hash>/. Running git from within that clone confirms the history is present:bash
git log -1 --format=%H -- site/content/endeavours/henge.md # returns: daa0b2c43548c16f9fdde191e66b0269f9715293However
Page.GitInfois nil. Adding a debug line:go
{{ warnf "File path: %q" .Page.File.Filename }}Shows:
Root cause:
The blobless clone maps the file as
site/content/endeavours/henge.md(relative to the git repo root), but Hugo is looking upcontent/endeavours/henge.md(relative to the module root). The offset between the module root (site/) and the git repo root is not accounted for.Workaround:
Move
go.modto the git repo root. The module path no longer includes the subdirectory, so the cache path strips correctly and the repo-relative path matches the blobless clone.Expected behaviour:
Page.GitInfoshould populate correctly regardless of wherego.modis located within the git repo. The path translation should account for the offset between the module root and the git repo root.Related:
dfece5b(the 0.157.0 fix that introduced the blobless clone mechanism), issue #5533