My site has multiple archetypes, including “events” and “ingredients”.
The front matter of an “ingredient” has some variables and looks like this:
---
draft: false
name: "apple A"
category: "fruit"
color: "red"
---
The front matter of an “event” is more complex and looks like this:
---
draft: true
details:
- specials:
recipes:
- recipe:
company: "Foodtruck ABC"
chef: "John"
name: "Pancake"
short_description: "The winning pancake with [[apple a]]!"
- recipe:
company: "Foodtruck XYZ"
chef: "Sarah"
name: "Cupcake"
short_description: "Best cupcakes with [[apple a]], [[mango]] and [[chocolate]]"
---
Each word in details.specials.recipes.recipe.short_description
that starts with specific characters [[
and ends with ]]
reflects the name
variable of an “ingredient” post.
In the front-end, this should result in the following HTML. Please note the:
- working hyperlink to the related “ingredient” (“apple a” in this example)
- values “fruit” and “red” from the page variable
category
andcolor
.
<div>
<h1>Pancake</h1>
<div>by John</div>
<div>The winning pancake with <a href="https://site.com/ingredients/apple-a"><div>category: fruit</div><div>color: red</div>apple a</a>!</div>
</div>
<div>
<h1>Cupcake</h1>
<div>by Sarah</div>
<div>Best cupcakes with <a href="https://site.com/ingredients/apple-a"><div>category: fruit</div><div>color: red</div>apple a</a>, <a href="https://site.com/ingredients/mango"><div>category: fruit</div><div>color: green</div>mango</a> and <a href="https://site.com/ingredients/chocolate"><div>category: snacks</div><div>color: brown</div>chocolate</a>!</div>
</div>
In many topics I’ve read that it is not possible to use shortcodes in front matter, so that is why I try to achieve this with special characters like [[
and ]]
. Is this possible?