#13085·hugo

Add hugo.BuildCount

Author: bepCreated Nov 23, 2024Updated Sep 26, 2026
LabelsProposalb1

See https://discourse.gohugo.io/t/how-should-i-store-dynamic-data-in-the-page-object-hugo-serve-w/52514/2

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:

handlebars
{{- 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