Is it possible to include variables from the front matter within the markdown content? Example:
---
title: My Blog Post
---
Hello world, this is a post titled {{ .Page.Title }}
If I can do this, it’ll help me avoid redundancy, for example, embedding an image thumbnail into the single post’s rendered content and also making a preview of the image thumbnail in the snippets I’m building for the list view. In general I’d like to “parameterize” my content quite a bit more if possible, so I’d use this in a lot of ways.
One possibility seems to be writing a shortcode. Is that the right answer?
Hmm, admittedly I haven’t tried that… so not sure if it will work… try $.Param instead (put that dollar sign). The $ will set a context where that Param should be called.
I didn’t try the second option. But this works for all parameters I tried, including built-in ones like description and random stuff I just put into the front matter. It also works for parameters that don’t exist in the front matter. Thanks to all who helped!
Thanks for responding @regis, If the front matter parameter you’re fetching is a date, how would you format that in the markdown?
{{< param Date.Format "2 jan, 2006" >}} doesn’t work. Of course, one could create a custom shortcode for dates, but I was wondering if the universal shortcode suggested above would suffice.