I’m making a little website to keep my own recipes on, and wanted to add ingredients as a taxonomy.
So for example I have potatoes
as an ingredient, and when I can add this to any recipe and get all recipes with potatoes
in it very easily thanks to ingredients
being a taxonomy:
ingredients:
- potatoes
- butter
However, often I want to add an amount of potatoes to the ingredient list, or some extra information like sliced potatoes
or cubed potatoes
.
So I tried making the ingredients
a map:
ingredients:
potatoes: 2 cubed potatoes
butter: a lot of butter
This doesn’t seem to work, giving the error Invalid ingredients
. When making it a list again it works, but uses the whole map as the term, so isn’t usable:
ingredients:
- potatoes: 2 cubed potatoes
- butter: a lot of butter
This will give map[potatoes:2 cups diced peeled potatoes]
as an ingredient in the ingredients taxonomy, rather than using just potatoes
.
So the solution I could make work was to add a second variable in the front-matter that has the extra information about the ingredients. But this required me to keep two lists in sync manually, and I’m looking for a nicer solution:
ingredients:
- potatoes
- butter
ingredients_meta:
- 2 cubed potatoes
- a lot of butter
So I was wondering, is it possible to add ingredients
as a taxonomy to Hugo, but add extra metadata to each term (that’s different for every recipe)? Or is there a way to generate extra pages based on values in front-matter of other pages, similar to the taxonomy pages, but with my own logic in them?