From 739eaf55c2aae0f674cf8498ddbd29f80bcd24b0 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Tue, 7 Jul 2026 17:33:21 +0200 Subject: [PATCH] fix(head): drop misleading commit-hash fallback for application version hugo.CommitHash is the Hugo executable's build commit, not the site's, so it rendered a constant misleading value. Resolve the application version from config or HUGO_APPLICATION_VERSION only; render no tag when neither is set. Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 2 +- layouts/_partials/assets/app-version.html | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 422565bc..f7e1bc98 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Set `[params.application]` to advertise your site's own release version in the d name = "My App" ``` -This renders ``. The version resolves from `params.application.version`, else the `HUGO_APPLICATION_VERSION` environment variable (set this in your build / CI pipeline), else the short Git commit hash when `enableGitInfo` is on. Sites that omit `[params.application]` render no such tag. +This renders ``. The version resolves from `params.application.version`, else the `HUGO_APPLICATION_VERSION` environment variable (set this in your build / CI pipeline). Sites that omit `[params.application]`, or that set neither a config value nor the environment variable, render no such tag. ## Contributing diff --git a/layouts/_partials/assets/app-version.html b/layouts/_partials/assets/app-version.html index 2b1c3888..e94af7b6 100644 --- a/layouts/_partials/assets/app-version.html +++ b/layouts/_partials/assets/app-version.html @@ -8,8 +8,8 @@ tag. Precedence: 1. site.Params.application.version (explicit config override) 2. HUGO_APPLICATION_VERSION env var (CI / build injection) - 3. hugo.CommitHash (short) (local builds with enableGitInfo) - Returns an empty string when none resolve. A leading "v" is stripped. */}} + Returns an empty string when neither resolves (no tag is rendered). + A leading "v" is stripped. */}} {{- define "_partials/inline/env-app-version.html" -}} {{- return getenv "HUGO_APPLICATION_VERSION" -}} {{- end -}} @@ -21,8 +21,5 @@ {{- if not $version -}} {{- $version = partial "inline/env-app-version.html" . -}} {{- end -}} -{{- if not $version -}} - {{- with hugo.CommitHash -}}{{- $version = printf "g%s" (substr . 0 7) -}}{{- end -}} -{{- end -}} {{- $version = $version | default "" | strings.TrimPrefix "v" -}} {{- print $version -}}