Use page parameter in included headless snippet


I’d like to include a text snippet from a headless bundle in multiple different content pages, and would like to use a parameter from the content page in the headless snippet, so it gets resolved to a different value on the different content pages. That way I need to update the snippet only in the headless bundle, but still can have minor differences in the content pages (for example, the name of a product).

To make it a bit clearer:


The idea is that and have a parameter in their frontmatter (productname: Product1, productname: Product2), and use a simple shortcode to include the file.
{{< include "headless/" >}} has some text and references the productname parameter, something like:
This product is called {{< param ".Page.Params.productname" >}}

The expected output is:

    This product is called Product1

    This product is called Product2

However, I couldn’t get it work (when Hugo processes the snippet file, it complains about the missing productname parameter):
Building sites … ERROR 2020/06/05 06:58:19 Param ".Page.Params.productname" not found: "/src/content/headless/doc/

Has anyone got something like this working in Hugo?

Kind Regards,

The errors are text, you should include them when posting to #support.

Sounds like you are calling the shortcode in a content that doesn’t have the param for productname.

Hi, I’ve added the error message to the original post.

I do define the productname parameter in the frontmatters of the product1/ files, but get the error despite that. It looks like Hugo tries to process the included content before including it into the product pages.

I’ve tried to experiment with using .Content and .RawContent in the include shortcode, and changing the < to % where I call the shortcode, but couldn’t find a combination that gives the desired output.

Please share your repo or a reproducible repo with your issue. I was going to ask for the contents of, but I don’t like asking a new question each time. If we can reproduce your error, we can fix it a lot faster. :slight_smile:

Hi maiki,
Thanks a lot for your help, you can find a minimal repo at

Hi @fekete-robert, are you able to solve this? I am trying to achieve the same expected output as you

As a test, I ran your repo on my local and changed the file like below and there’s no error,


productname: Product3
This product is called {{< param "productname" >}}

but it did not give a correct expected output

    This product is called Product3

    This product is called Product3

It seems this param shortcode read the param from the snippet file (headless page) instead of the front-matter params in the page where its parent’s shortcode is located

the source for this built-in param shortcode (ref):


{{- $name := (.Get 0) -}}
{{- with $name -}}
  {{- with ($.Page.Param .) }}
    {{ . }}
  {{ else }}
    {{ errorf "Param %q not found: %s" $name $.Position }}
  {{ end -}}
{{- else }}
  {{ errorf "Missing param key: %s" $.Position }}
{{ end -}}

Hi, unfortunately I couldn’t get it work, so I don’t use page parameters in snippets.