Skip to content

Add hugo.BuildCount #13085

Open
Open
@bep

Description

@bep

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions