Processing order or how to refer to something defined later

Hi,

currently I struggle with a problem regarding processing order. My problem:
I have a shortcode for a repeating HTML structure. Inside my shortcode I set
a .Page.Scratchto access the variable in my template. Actually I need to put the content of that Scratch in the HTML head, before any shortcode usage.

I verified that I can access the Scratch for example in the footer after the shortcode usage. However in the head it is not yet defined.

Does Hugo offer a solution for this. I only found a Thread where it was said that shortcodes would always be processed first. But I think it changed with v0.40.0.

What options do I have?

  • Is there a variable I can put in my page head which is parsed after all content?
  • I already know hasShortcode, but is there a way to iterate over all my shortcodes on my own to extract my data when and where I want?
  • only other solution coming up to my mind is defining all my shortcode usages as page resources and change the shortcode to refer to the resource and also use the resource for my HTML head

Thanks in advance