I have a couple sites that I’d like to have major sections on the homepage for certain tags. For example, in my Coffee Log (source is here) I might have to have an index that filtered by continent. I know I could use a separate parameter for this, but I’d like to play with the page a little with existing tags before I bite the bullet and add a separate parameter value everywhere.
I tried putting this in the main index (just to play with this idea:)
{{ range where .Data.Pages "Params.tags" "ethiopia" }}
{{ template "chrome/roast.html" . }}
{{ end }}
and it found nothing. I figure the problem is that tags is an array, but as far as I can tell there’s no “contains” operator.
You can try slice, but also check out the templating docs on taxonomies. might be something there. But, the Related Content stuff is likely your best bet.
If interested, my plan is to make a landing page where there is a separate list of a certain (but not all) tags. So for example in one of my repos I intend to make a “reference” section, a “projects” section, etc.
I don’t really care to automatically generate related posts to the current post as much as large sections for my corpus. The above is easier to understand and does precisely what I want, and no more, with no other configuration.
I understand, and that’s a good approach (intersect). Not to be so adamant about it (the difference is really just performance, so if you don’t notice it, it’s not important), but this would be the same thing (I think, untested) for Related: {{$foo := .Site.RegularPages.RelatedTo (keyVals "tags" "tagname")}}
huh, you’re right, it’s exactly the same output! I do sorta still prefer my way, only if it’s because it’s clearly just two operations, but this is good to know.