Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Set `[params.application]` to advertise your site's own release version in the d
name = "My App"
```

This renders `<meta name="application" content="My App <version>">`. 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 `<meta name="application" content="My App <version>">`. 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

Expand Down
7 changes: 2 additions & 5 deletions layouts/_partials/assets/app-version.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<meta name="application"> 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 -}}
Expand All @@ -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 -}}
Loading