Add hugo.BuildCount
Author: bepCreated Nov 23, 2024Updated Sep 26, 2026
LabelsProposalb1
Deprecating Page.Scratch was the right thing to do, but the example above may be a rare useful example of the old behavior.
It would be simple to add a hugo.BuildCount method (I guess starting at 1).
In the topic above, you could possibly do:
{{- if ne (.Page.Store.Get "myCounter") hugo.BuildCount -}}
<script type="text/javascript" src= '(...)'></script>
<style>(...)<\style>
{{- end -}}
{{- .Page.Store.Set "myCounter" hugo.BuildCount -}}/cc @jmooring
Source: gohugoio/hugo