{{< param testparam >}} in shortcode doesn't work - doc error?

It seems to me that this page incorrectly identifies the following as being correct syntax:

{{< param testparam >}}

for a shortcode accessing front matter.

I believe the correct syntax would be:

{{< $.Page.Params.testparam >}}

I thought I’d check here first before creating an issue or pull request.

Agree? Am I right?

It also shows this example:

{{< param "my.nested.param" >}}

which should be:

{{< $.Page.Params.my.nested.param >}}

The documentation is correct.

param here is an internal shortcode that calls {{ .Param "testparam" }} which is documented here:

EDIT: I’m not sure when that shortcode was added, so you may wish to try with latest Hugo.

That’s interesting. I was on hugo v0.100.0, but just updated to v0.102.0 with the same result.

I have the following:

{{ range $.Page.Params.overview.toc }}

That works great.
If I do this:

{{ range param "overview.toc" }}

it does not work. I get:

parse failed: template: shortcodes/insightsToc.html:4: function "param" not defined

I think you are confusing the shortcode param with the function .Param that can be used in a partial. The shortcode is used in Markdown like:

A Wonderful Story
By {{< param author >}}

while the function is used in a partial or layout.

See:

@cshoredaniel, yes, you are correct! Thank you for straightening me out.

param is a built-in shortcode, and I’m trying to call a built-in shortcode inside of a shortcode, which is not going to work. Got it!

Thanks again!

1 Like

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