diff --git a/exampleSite/test.bat b/exampleSite/test.bat index 08473ffd28..ce4200d998 100644 --- a/exampleSite/test.bat +++ b/exampleSite/test.bat @@ -3,6 +3,7 @@ set /p version=<..\layouts\partials\version.txt echo %version%>metrics.%version%.txt echo disableAssetsBusting=true>>config.toml echo disableGeneratorVersion=true>>config.toml +echo disableRandomIds=true>>config.toml hugo --templateMetrics --templateMetricsHints --cleanDestinationDir --destination public.%version% >> metrics.%version%.txt move /Y metrics.%version%.txt public.%version%\metrics.txt 2>&1 >NUL git restore config.toml diff --git a/layouts/partials/make-random-md5.hugo b/layouts/partials/make-random-md5.hugo index d355dde35d..e6dba739df 100644 --- a/layouts/partials/make-random-md5.hugo +++ b/layouts/partials/make-random-md5.hugo @@ -1,8 +1,13 @@ -{{- $random := "" }} -{{- $set := split "012345abcdefghijklmnopqrstuvwxyz" "" }} -{{- range (seq 16) }} - {{- with ($set | shuffle | first 1) }} - {{- $random = printf "%s%s" $random . }} +{{- $context := . }} +{{- if (ne $context.Site.Params.disableRandomIds true) }} + {{- $random := "" }} + {{- $set := split "012345abcdefghijklmnopqrstuvwxyz" "" }} + {{- range (seq 16) }} + {{- with ($set | shuffle | first 1) }} + {{- $random = printf "%s%s" $random . }} + {{- end }} {{- end }} -{{- end }} -{{- md5 $random }} \ No newline at end of file + {{- md5 $random }} +{{- else }} + {{- printf "00000000000000000000000000000000" }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/expand.html b/layouts/partials/shortcodes/expand.html index 3998920d56..e201afec15 100644 --- a/layouts/partials/shortcodes/expand.html +++ b/layouts/partials/shortcodes/expand.html @@ -6,7 +6,7 @@ {{- if eq (printf "%T" $expanded) "string" }} {{- $expanded = (eq $expanded "true") }} {{- end }} -{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo") .id }} +{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $context.Page) .id }} {{- with $context }}