What I want to achieve is to assign a tag or value to each of my recipes, so then I can make a loop based on that tag on the recipes/_index.md page. The existing jekyll code is still in place, I’m wanting to replace it pretty much like for like.
I’ve also noticed that when I add pages with their actual names spaghetti-carbonara.md they get included in the blog posts. Will they always need to be named spaghetti-carbonara\_index.md?
Finally … I was not sure why you are writing code in the _index.md file ? I think this is your second question? … the code should be in theme / layouts
But …depending on the Hugo theme you have - it should already support generating taxonomy pages for you
then all you need to do is add your custom taxonomies to your config.toml …
The code on github builds fine, I’m developing the site locally without issue.
I think you may have misunderstood my aim. What I want to do is have a tag I can reference to build a list of pages that have contain that tag.
If you look at the current liquid code in recipes.md (I appreciate it may need moving), it will check every page for type: recipe_meal then build a list of all those pages, same for recipe_snack and all other tags I categories recipes using.
The reason I’m doing this is because I have a number of ‘sub pages’ like the above, if you check my current Jekyll blog you’ll see what it produces.
The theme I’m using is one I made myself, so it may not support taxonomies like a ‘proper’ theme would.
My second question is more about file naming and permalinks, if I add spaghetti-carbonara.md, it will appear in my list of blog posts. If I make add it under a directory spaghetti-carbonara\_index.md it does not. I want to know if this is the proper practice for making these ‘sub pages’.
I understand what you are talking about and this working on my site nothing strange there - it works out of the box… it has tags and categories – these are built in the them
I added a custom taxonomy series – the custom taxonomy links related articles … series example
Hugo is clever - you dont need to put type: recipe_meal in your front matter … so long as your recipes are saved in the folder called recipes under the content folder … then you just build a query that looks for the content in that folder …
keep your hugo content folders flat -
top level … /content/
has a subfolder
/recipes/
_index.md
keto-stirfry.md
keto-ragu.md
keto-pancakes.md
Thanks for your help again, I feel as though I’m getting fairly close now but I’m still not getting anything rendering when I add that code.
I’ve assigned a respective recipetype: value to each of my recipes, added these values to my config.toml, assigned layout: recipes to my recipes\_index.md page and added your code above, but made tweaks based on this post.
<ul>
{{ range first 3 .Site.Taxonomies.recipetype.meal }}
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a>
</li>
{{ end }}
</ul>
I still get no output however, when I use the full " Example: List All Taxonomies, Terms, and Assigned Content" code, I do get output, but none of my pages seem to be assigning their taxonomies correctly.
I haven’t pushed this latest code to github, but if you’d like me to, I’ll create a separate branch for it.