# .Store keeps values over server reloads

**URL:** <https://discourse.gohugo.io/t/store-keeps-values-over-server-reloads/56518>\
**Category:** support\
**Created:** [January 7, 2026, 4:19am UTC](https://discourse.gohugo.io/t/store-keeps-values-over-server-reloads/56518 "2026-01-07T04:19:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [January 7, 2026, 4:19am UTC](https://discourse.gohugo.io/t/store-keeps-values-over-server-reloads/56518/1 "2026-01-07T04:19:12Z")

</div>

Something that worked until recently is this “system” I used:

- an SVG icon shortcode `{{< icon name="bla" >}}`
- if the specific icon is used the first time the shortcode echoes a `<symbol>` tag with the icon and a `<use>` tag with a reference to that symbol
- if the specific icon is used a second time then the shortcode only echoes the `<use>` tag - some kB saved.

This worked fine with scratch, until that got deprecated. When I just looked over it to adapt to the latest code, I realised, that `.Store` apparently stays saved over server reloads. So when I change something in the template of a page, the icons disappear, because the first (for this server reload) call to the icons finds a note in the store that it was already echoed.

After a `hugo server` starts the icons are displayed. Once I change something, they disappear. Running the build of course works fine. The same happens everywhere I did have scratches.

Is there any way to somehow define a scratch page wide like “in the olden days” that is created new when the page/server is reloaded? Maybe I am just missing something fundamental here.

The layout in question (I tried with `page`, `hugo`, and `site` for the `.Store` but all lead to the same behaviour):

> **icon.html**
>
> ```auto
> ...
> {{- $icons := page.Store.Get "icons" -}}
> <svg width="{{- $width -}}" height="{{- $height -}}" class="icon icon-{{- $iconname }} {{ $class -}}">
> {{ if $icons}}
> {{- if compare.Eq (collections.Index $icons $iconname) true -}}
> {{- /* symbol already included */ -}}
> {{- else -}}
> {{- /* include symbol definition */ -}}
> {{ partial "inline/dnb/icons/lucide/get-icon.html" (dict "iconname" $iconname) }}
> {{- end -}}
> {{ else }}
> {{- /* first call to the shortcode, include symbol definition */ -}}
> {{ partial "inline/dnb/icons/lucide/get-icon.html" (dict "iconname" $iconname) }}
> {{ end }}
> <use href="#{{- $iconname -}}"{{ with .width }} width="{{- . -}}"{{ end }}{{ with .height }} height="{{- . -}}"{{ end }} />
> </svg>
> 
> {{ define "_partials/inline/dnb/icons/lucide/get-icon.html" }}
> {{ $iconname := .iconname }}
> {{ $iconpath := fmt.Printf "icons/lucide/%s.svg" $iconname }}
> {{ $content := "" }}
> {{ with resources.Get $iconpath }}
> {{ $content = .Content | safe.HTML }}
> {{ $content = replaceRE `<svg[\t\r\n]+` `<svg ` $content }}
> {{ $replaceId := fmt.Printf "id=%q" $iconname | safe.HTMLAttr }}
> {{ $replacement := fmt.Printf "<symbol %s " $replaceId }}
> {{ $content = strings.Replace $content "<svg " $replacement 1 }}
> {{ $content = strings.Replace $content "</svg>" "</symbol>" 1 }}
> {{ page.Store.SetInMap "icons" $iconname true }}
> {{ end }}
> {{ $content | safe.HTML }}
> {{ end }}
> 
> ```

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [January 7, 2026, 9:03am UTC](https://discourse.gohugo.io/t/store-keeps-values-over-server-reloads/56518/2 "2026-01-07T09:03:02Z")

</div>

created a one pager, where I added the shortcodes: (v0.154.2)

> [@davidsneighbour](#):
>
> So when I change something in the template of a page  
> Once I change something, they disappear.

really? I can change the index.md, home and base template … and get the display.

only when I’m changing the shortcode or your inline partial it breaks.

HINT: following the [warning for global page function](https://gohugo.io/functions/global/page/#article) I would use the `.Page` method within _shortcode_ and pass it to the inline.

```auto
{{ $page := .Page }}
{{- $icons := $page.Store.Get "icons" -}}
...
{{ partial "inline/dnb/icons/lucide/get-icon.html" (dict "iconname" $iconname "page" $page ) }}

...
{{- define "_partials/inline/dnb/icons/lucide/get-icon.html" -}}
...
{{ .page.Store.SetInMap "icons" $iconname true }}

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [January 7, 2026, 9:40am UTC](https://discourse.gohugo.io/t/store-keeps-values-over-server-reloads/56518/3 "2026-01-07T09:40:23Z")

</div>

I have a video embed that adds some javascript on the first load in the same way and it disappears every time I edit “something somewhere”. Interestingly both layouts with the store live in modules. I’ll play around on what changes each stops working. Maybe I need to “watch” module changes with a cachebuster?

I think in this context it’s ok to take the top-level page object. I want to output each individual icon once per pageload, not once per page item (content item), I think. I’ll test that tomorrow morning with a couple of posts.

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [January 7, 2026, 9:58am UTC](https://discourse.gohugo.io/t/store-keeps-values-over-server-reloads/56518/4 "2026-01-07T09:58:48Z")

</div>

I’ve been successfull with adding

```auto
{{.Store.Delete "icons" }}

```

to baseof or home (I have no pages and sections in my test site -

one could that wrap in a conditional IsDevelopment or hasShortcode, or delete on retrieval but think we skip that, assuming that deleting a key that’s not present is as fast as checking that before.

> [@davidsneighbour](#):
>
> Maybe I need to “watch” module changes with a cachebuster?

not something I can give valuable guidance on.
