# Storing and retrieving from global scratch pad

**URL:** <https://discourse.gohugo.io/t/storing-and-retrieving-from-global-scratch-pad/54779>\
**Category:** support\
**Tags:** shortcodes\
**Created:** [May 18, 2025, 9:08pm UTC](https://discourse.gohugo.io/t/storing-and-retrieving-from-global-scratch-pad/54779 "2025-05-18T21:08:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgadey](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgadey/32/23984_2.png) [@pgadey](https://discourse.gohugo.io/u/pgadey)\
**Post date:** [May 18, 2025, 9:08pm UTC](https://discourse.gohugo.io/t/storing-and-retrieving-from-global-scratch-pad/54779/1 "2025-05-18T21:08:26Z")

</div>

Hi! I’m having issues storing and retrieving information from the global Hugo scratch pad as documented here: [hugo.Store](https://gohugo.io/functions/hugo/store/). I’m not a programmer, so I don’t even how to describe what’s going wrong very well; please bear with me.

The thing that I intend to do is this: Lots of different posts on my blog end with Links sections. I would like to be able to wrap the content of each Links section in a shortcode which gathers up all the links in that section, so that they can be dumped on a Bookmarks page elsewhere.

Here’s what I’ve tried so far: I have two shortcodes `gather` and `dump` which are implemented as follows:

`gather.html`

```auto
{{/* gather the relevant information in the global scratchpad named $dest */}}

{{ $dest := .Get "dest" }}
{{ $exists := hugo.Store.Get $dest }}

{{ if not $exists }}
	{{ hugo.Store.Set $dest .Inner }}
{{ else }}
	{{ hugo.Store.Add $dest .Inner }}
{{ end }}

{{ .Inner | safeHTML }}

```

`dump.html`:

```auto
{{/* dump the relevant information from the global scratchpad named $source */}}

{{ $source := .Get "source" }}

{{ hugo.Store.Get $source | safeHTML }}

```

The issue that I’m running in to is this: When I actually try to use `gather` and `dump`, I get this weird result where `dump` produces many copies of the information which was `gather`-ed up. Moreover, it seems that the `dump` also has old versions of the content in global scratch pad. (See screenshot below.)

I put a minimal example on Github here:

> **[gather-dump/content at master · pgadey/gather-dump](https://github.com/pgadey/gather-dump/tree/master/content)**
>
> A minimal working example of gather-dump shortcodes. - pgadey/gather-dump

For example, this is what I see when running the minimal example locally using `hugo server`.

 ![Screenshot_2025-05-18_16-58-13](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/e/9/e94c1db54d26d427b3c1c242f8bfb1cfae29f266.png)

For what it is worth, here is my `hugo env` output:

```auto
hugo v0.144.0-b289b17c433aa8ebf8c73ebbaf4bed973ac8e4d5 linux/amd64 BuildDate=2025-02-17T16:22:31Z VendorInfo=gohugoio
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.24.0"

```

Many thanks for your patience and support!

---

<div class="post-metadata">

**Author:** ![pgadey](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pgadey/32/23984_2.png) [@pgadey](https://discourse.gohugo.io/u/pgadey)\
**Post date:** [May 20, 2025, 1:31am UTC](https://discourse.gohugo.io/t/storing-and-retrieving-from-global-scratch-pad/54779/2 "2025-05-20T01:31:55Z")

</div>

After writing this, sleeping on it, and playing around with it some more, I think the problem is this: `hugo server` doesn’t reset the global scratchpad between rebuilds. This means that the content of `hugo.Store` just keeps accumulating more and more stuff every time that page is rendered. This explains the weirdness in the screenshot.

If I build the page for “production” then I don’t have the weird reduplication.

---

<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:** [May 22, 2025, 1:32am UTC](https://discourse.gohugo.io/t/storing-and-retrieving-from-global-scratch-pad/54779/3 "2025-05-22T01:32:12Z")

</div>

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