I have two overlapping categories on my blog (micro and photo) and for the life of me I can’t work out how to filter photo out of micro.
Every way I try using Hugo examples doesn’t work (crash) or gives me zero results.
😢
I have two overlapping categories on my blog (micro and photo) and for the life of me I can’t work out how to filter photo out of micro.
Every way I try using Hugo examples doesn’t work (crash) or gives me zero results.
😢
@gr36 Depending on your end goal, you could use a modified version of what’s in this conversation. Thanks to @sod for helping on that.
@gr36 That looks like you’re setting the variable to something then overwriting it. Are you trying to list all posts that have a Photo?
@Mtt thats right, I find it easier to debug than all the interlocking where's.
I'm trying to list all posts in category micro that are not also in category photo
@gr36 Something like this may work. I typed it out on my phone and haven’t tested, so there may be a typo:
{{ if and (in .Params.categories "micro") (not (in Params.categories "photo")) }}
<h3>{{ .Title }}</h3>
{{ end }}
@Mtt thanks. That works for going through a loop great.
I just need to figure out how to do this to produce a range 🤔
@gr36 One solution using complement
: {{ range .Site.Taxonomies.categories.micro.Pages | complement .Site.Taxonomies.categories.photo.Pages }}
.