Use eq to include a .Kind while using slice?

I don’t know to start looking for how to do this; eq might be what I need, but I don’t know how to mix that with slice and taxonomies.

I use this to exclude all taxonomies from my sitemap.xml:

{{- $exclude := slice “taxonomy” -}}
{{ if not (in $exclude .Kind) }}

My taxonomies are in config.toml:

[taxonomies]
tag = “tags”
category = “categories”
author = “authors”

But now I want to include authors in the sitemap. How can I exclude all taxonomies - like tags and categories - except for authors? Or, only include the taxonomies I want?

Have a look at this example: https://gohugo.io/functions/union/#or-filter-in-where-query

Edit:

For using in an if statement: or

{{ $include := slice "authors" }}
{{ if (in $include .Type) }}

should implicitly include only the ones you want

Thanks, that works and includes only authors. But that now excludes all my other content, like posts and pages. :slight_smile:

I tried what I think is “if is a taxonomy, then select only authors”, but this doesn’t work:

{{ $taxonomy := .Site.Taxonomies }}

{{ if (in $taxonomy .Type) }}

{{ $include := slice “authors” }}
{{ if (in $include .Type) }}

{{ end }}

{{ $in := slice "authors" }}

{{ if or  (in $in .Type)      (not (eq .Kind "taxonomy")) }}
   true:   ^ if authors   OR   ^ not a taxonomy .Kind

Thanks! That works great.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.