Using page frontmatter param in shortcode

This question asks exactly what I want to do, but I’m misunderstanding the solution presented by @bep.

In my case, I want to use the built-in “figure” shortcode, and set the named parameter “src” to a front matter variable, like:

mysrc: theimage.jpg

{{< figure src="{{< param mysrc >}}" >}}

I’ve attempted quite a few syntax variations, so I think I must e going about it the wrong way. I considered nested shortcodes, but can’t envision that with named parameters.

Thank you

Hi there,

The topic you were replying to is a few years old now, so I opened a new one for you.

To answer your question: you can access the page params from inside the shortcode. You can’t nest shortcodes in the way you are trying.

You can write your own shortcode based on the internal figure shortcode modified to use the param as discussed in that original topic.

1 Like