Use shortcode within markdown to inject contents in arbitrary location on page

I’ve started using .Page.Store instead:
https://gohugo.io/functions/store/

In contrast to the .Scratch method, this Scratch is not reset on server rebuilds.

The .Store value is initialized when the content is rendered, but we need the value before the content is rendered. Instead of trying to remember the rendering sequence and the nuances of concurrency, I always force content to be rendered to a “no-op” variable if I need a .Scratch or .Store value before calling .Content in a template.

See this post for a list of methods that cause content rendering.

I’m not sure I’ve seen a problem when building a site, but I’ve definitely seen a problem when editing templates while running hugo server.

You can obviously create a footnote that appears immediately below the .Inner content, but I can’t think of a way to place that footnote at the bottom of the page; you’re rendering the shortcode content outside of page rendering.

1 Like