Pass Front Matter parameter to YouTube shortcode

For video posts I have a user-defined piece of front matter

youtubeid: "KsLi7HgSuhI"

I want to pass that parameter to the youtube shortcode in the body of the post.

{{< youtube .Params.youtubeid >}}

That gets me an “unrecognized character in shortcode action: U+002E ‘.’ Note: Parameters with non-alphanumeric args must be quoted” error.

I have tried .Page.Params.youttubeid, $.Page.Params.youtubeid, params youtubeid, all with out success.

If I put quotes around what I am passing into the youtube shortcode, then that string gets used as the video id. How do I embed the front matter parameter in the shortcode so that it provides it’s value to the shortcode?

You can’t pass front matter values as shortcode parameters.

Instead, override the embedded youtube shortcode by placing a copy in layouts/shortcodes, and modify it to get the front matter value.

In that case I’ll just paste the YouTube ID into the shortcode itself. I was being overly clever by putting a parameter in the front matter for video posts. But since all the post has is the video, just as easy to post directly into the shortcode.

Thanks for the explanation.