# Use eq to include a .Kind while using slice?

**URL:** <https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229>\
**Category:** support\
**Created:** [May 3, 2020, 12:08am UTC](https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229 "2020-05-03T00:08:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluedogranch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bluedogranch/32/10538_2.png) [@bluedogranch](https://discourse.gohugo.io/u/bluedogranch)\
**Post date:** [May 3, 2020, 12:08am UTC](https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229/1 "2020-05-03T00:08:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [May 3, 2020, 1:33am UTC](https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229/2 "2020-05-03T01:33:52Z")

</div>

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

Edit:

For using in an `if` statement: `or`

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

```

should implicitly include only the ones you want

---

<div class="post-metadata">

**Author:** ![bluedogranch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bluedogranch/32/10538_2.png) [@bluedogranch](https://discourse.gohugo.io/u/bluedogranch)\
**Post date:** [May 3, 2020, 4:26pm UTC](https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229/3 "2020-05-03T16:26:18Z")

</div>

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

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 }}

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [May 4, 2020, 12:33am UTC](https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229/4 "2020-05-04T00:33:09Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![bluedogranch](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bluedogranch/32/10538_2.png) [@bluedogranch](https://discourse.gohugo.io/u/bluedogranch)\
**Post date:** [May 4, 2020, 1:33am UTC](https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229/5 "2020-05-04T01:33:18Z")

</div>

Thanks! That works great.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [May 6, 2020, 1:33am UTC](https://discourse.gohugo.io/t/use-eq-to-include-a-kind-while-using-slice/25229/6 "2020-05-06T01:33:19Z")

</div>

Closed on May 6, 2020, 1:33am UTC

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