Get pages with multiple (but not all) taxonomy terms

Hello, I’ve tried looking through the docs and previous forum posts for a similar issue but I’m still having some issues.

I am trying to return pages from a specific set of taxonomy terms, as opposed to one or all.

For example, if I have the following tags [“education”, “sports”, “life”, “technology”] - I would like to return pages for two out of the four, say [“education”, “technology”].

I have defined a json file in the data directory which I have created a Scratch for on the page to access these partial taxonomy lists.

The below is able to access pages for a single taxonomy, is there a way to insert an array or create a nested range? I’ve tried both “in” and “intersect” using where, but perhaps my syntax is incorrect.

    {{ range (index.Site.Taxonomies.tags "education") }}
      <li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a></li>
    {{ end }}

This is what I attempted using where:

{{ range (where .Site.Pages "Params.tags" "in" $groupedTags) }}
    <li> ... </li>
{{ end }}


You can try union, something like:

{{ $one := (index site.Taxonomies.tags "one").Pages }}
{{ $two := (index site.Taxonomies.tags "two").Pages }}

{{ $combined := $one | union $two }}

Ugh, I got it to work. My scratch contained the JSON as a string - converted it to an array and everything works. :sweat_smile::sob: