[Solved] Passing front matter variables to shortocode

---
categories: [Interview, News]
tags: [Events, Food, Hockey]
---

I have a markdown file with front matter like so. What I would like to do is be able to pass in a front matter parameter directly into the shortcode.

{{< shortcode list=tags >}} or {{< shortcode list=categories >}}

Is there a way to directly pass front matter into shortcodes like so?

1 Like

I would just do it the other way around, read the params from the shortcode:

{{ .Page.Params.myParam }}

If you want some dynamics to this, just pass the name of the param as a shortcode parameter, then:

{{ index .Page.Params (.Get "some-shortcode-param" ) }}

Or something.

4 Likes

Ohhh that is beautiful. Thank you, I did not consider that as an option.

A post was split to a new topic: Using page frontmatter param in shortcode