# .Store empty after server restart

**URL:** <https://discourse.gohugo.io/t/store-empty-after-server-restart/46935>\
**Category:** support\
**Tags:** shortcodes\
**Created:** [November 2, 2023, 3:20am UTC](https://discourse.gohugo.io/t/store-empty-after-server-restart/46935 "2023-11-02T03:20:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicola](https://avatars.discourse-cdn.com/v4/letter/n/41988e/32.png) [@nicola](https://discourse.gohugo.io/u/nicola)\
**Post date:** [November 2, 2023, 3:20am UTC](https://discourse.gohugo.io/t/store-empty-after-server-restart/46935/1 "2023-11-02T03:20:06Z")

</div>

Although `.Store` should maintain the content after a re-rendering of the page, it seems that it does not.  
The content disappears when I change the content of the \_index.md file.

I have this \_index.md:

```plaintext
+++
title = "Solutions"
type = "page"
description = ""
weight = 100
layout = "solutions"
+++

{{< content home >}}
This is the content inside the `top` shortcode, which will be captured for use in the template.
{{< /content >}}

```

This shortcode stores the content in .Store:

```plaintext
{{ $loc := .Get 0 }}
{{ $.Page.Store.Set $loc .Inner }}

```

And this is the template solution.html:

```plaintext
{{ $home := "" }}
{{ with .Page.Store.Get "home" }}
    {{ $home = . | safeHTML }}
{{ end }}

{{ $home }}

```

It works perfectly, but as soon as I change \_index.md, the content is not rendered anymore.

This is strange because it behaves like `.Scratch`.

Thank you for the help!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [November 2, 2023, 3:37am UTC](https://discourse.gohugo.io/t/store-empty-after-server-restart/46935/2 "2023-11-02T03:37:15Z")

</div>

> [@nicola](#):
>
> `This is the content inside the `top` shortcode`

Is there a “top” shortcode, or is the text incorrect? Assuming there isn’t a “top” shortcode, I suspect you are trying to access `Store` before the page content has been evaluated.

Force the content to be evaluated before accessing the `Store`.

layouts/\_default/solutions.html

```plaintext
{{ define "main" }}
  <h1>{{ .Title }}</h1>

  {{ $home := "" }}
  {{ $noop := .WordCount }} <---------- FORCES CONTENT EVALUATION
  {{ with .Page.Store.Get "home" }}
    {{ $home = . | safeHTML }}
  {{ end }}
  {{ $home }}

  {{ .Content }}
  {{ range .Pages }}
    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
  {{ end }}
{{ end }}

```

---

<div class="post-metadata">

**Author:** ![chrillek](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/chrillek/32/19797_2.png) [@chrillek](https://discourse.gohugo.io/u/chrillek)\
**Post date:** [November 2, 2023, 6:36am UTC](https://discourse.gohugo.io/t/store-empty-after-server-restart/46935/3 "2023-11-02T06:36:17Z")

</div>

> [@jmooring](#):
>
> Is there a “top” shortcode

I guess they were referring to the shortcode _above_ – top being a location, not a name

---

<div class="post-metadata">

**Author:** ![nicola](https://avatars.discourse-cdn.com/v4/letter/n/41988e/32.png) [@nicola](https://discourse.gohugo.io/u/nicola)\
**Post date:** [November 3, 2023, 7:34pm UTC](https://discourse.gohugo.io/t/store-empty-after-server-restart/46935/4 "2023-11-03T19:34:22Z")

</div>

It works perfectly.  
Thank you!

BTW, “top” had no particular meaning. It was only part of the different test text I created 😉

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [November 5, 2023, 7:34pm UTC](https://discourse.gohugo.io/t/store-empty-after-server-restart/46935/5 "2023-11-05T19:34:38Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
