# Listing members of a taxonomy in shortcode

**URL:** https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697
**Category:** support
**Created:** [July 18, 2016, 4:38pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697 "2016-07-18T16:38:45Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![wmakley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/wmakley/32/1441_2.png) [@wmakley](https://discourse.gohugo.io/u/wmakley)
#### Post date: [July 18, 2016, 4:38pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/1 "2016-07-18T16:38:45Z")

</div>

Is it possible to list the members of a taxonomy in a shortcode? I have a taxonomy of “states” and the following frontmatter:

`+++ states = ["MA", "CT"] +++`

The shortcode is:

`{{ range .Page.Site.Taxonomies.states.ct }} {{ .Render "summary" }} {{ end }}`

I have also tried:

`{{ range $.Site.Taxonomies.states.ct }}`

But nothing shows up. There is no error message. What am I doing wrong? How can I get a list of available taxonomy terms and their template variable names for debugging? (I just had to guess that “CT” would become “ct” from the docs.)

---

<div class="post-metadata">

### Author: ![waddles](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/waddles/32/1270_2.png) [@waddles](https://discourse.gohugo.io/u/waddles)
#### Post date: [July 19, 2016, 9:43am UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/2 "2016-07-19T09:43:31Z")

</div>

Have you tried dropping the .Page context to make it use .Site.Taxonomies ?

> **[Taxonomy Templates](https://gohugo.io/templates/taxonomy-templates/)**
>
> Taxonomy templating includes taxonomy list pages, taxonomy terms pages, and using taxonomies in your single page templates.

---

<div class="post-metadata">

### Author: ![wmakley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/wmakley/32/1441_2.png) [@wmakley](https://discourse.gohugo.io/u/wmakley)
#### Post date: [July 19, 2016, 1:26pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/3 "2016-07-19T13:26:51Z")

</div>

Yes, that didn’t work either. ☹

---

<div class="post-metadata">

### Author: ![waddles](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/waddles/32/1270_2.png) [@waddles](https://discourse.gohugo.io/u/waddles)
#### Post date: [July 19, 2016, 10:18pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/4 "2016-07-19T22:18:27Z")

</div>

I think you’re doing it wrong. Have you tried a dev version of hugo which may give you more info on failures?

I get the following errors when testing your shortcode:

```auto
ERROR: 2016/07/20 07:19:07 shortcode.go:565: error processing shortcode shortcodes/test.html
 ERR: template: shortcodes/test.html:2:3: executing "shortcodes/test.html" at <.Render>: Render is not a field of struct type hugolib.WeightedPage

```

1. The `.Render` function appears to be only available on Page content, not Taxonomies. Inside your range, you are in the context of a Taxonomy entry.
2. By performing a range over `.Site.Taxonomies.[taxonomies].[term]` you are then operating in the context of the Term, not the array of terms.

Hugo by default renders page content in list context at `/[taxonomy]/[term]/` using the template in `layouts/_default/list.html` but I think you want to include something like that inside your page content.

Probably what you want to do is this:

```auto
{{ $state := .Get "state" }}
{{ with (index .Page.Site.Taxonomies.states $state) }}
{{ range .Pages }}
{{ .Render "summary" }}
{{ end }}
{{ end }}

```

then call the shortcode as

```auto
{{% myshortcode state="ct" %}}

```

---

<div class="post-metadata">

### Author: ![wmakley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/wmakley/32/1441_2.png) [@wmakley](https://discourse.gohugo.io/u/wmakley)
#### Post date: [July 20, 2016, 7:22pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/5 "2016-07-20T19:22:05Z")

</div>

Thanks, switching to that at least causes an error message. With hugo I have a really hard time figuring out what values I am getting out of things. Your code (copied verbatim) causes this error:

`Started building site ERROR: 2016/07/20 15:20:35 shortcode.go:565: error processing shortcode shortcodes/practice_areas.html ERR: template: shortcodes/practice_areas.html:6:11: executing "shortcodes/practice_areas.html" at <index .Page.Site.Tax...>: error calling index: index of untyped nil`

The reason for the shortcode is we need to put these content cards within some page content, but not all. Hugo doesn’t seem to have a way to make a specific page that uses its own entirely custom template as a one-off.

---

<div class="post-metadata">

### Author: ![waddles](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/waddles/32/1270_2.png) [@waddles](https://discourse.gohugo.io/u/waddles)
#### Post date: [July 26, 2016, 10:04pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/6 "2016-07-26T22:04:00Z")

</div>

Using hugo 0.16? Have you tried with HEAD?

---

<div class="post-metadata">

### Author: ![Shiva](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/shiva/32/1982_2.png) [@Shiva](https://discourse.gohugo.io/u/Shiva)
#### Post date: [July 26, 2016, 10:52pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/7 "2016-07-26T22:52:03Z")

</div>

> [@waddles](#):
>
> Have you tried a dev version of hugo which may give you more info on failures?

Hi @waddles, I too get stumped with no error messages when running my Hugo locally. How do I get the “dev version” ? Do I need to install Go for that?

---

<div class="post-metadata">

### Author: ![waddles](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/waddles/32/1270_2.png) [@waddles](https://discourse.gohugo.io/u/waddles)
#### Post date: [July 27, 2016, 12:05am UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/8 "2016-07-27T00:05:42Z")

</div>

@Shiva [https://gohugo.io/overview/installing/#installing-from-source](https://gohugo.io/overview/installing/#installing-from-source) yes but go makes it really easy compared to traditional build environments.

---

<div class="post-metadata">

### Author: ![Shiva](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/shiva/32/1982_2.png) [@Shiva](https://discourse.gohugo.io/u/Shiva)
#### Post date: [July 27, 2016, 4:19am UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/9 "2016-07-27T04:19:22Z")

</div>

Thanks.

---

<div class="post-metadata">

### Author: ![wmakley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/wmakley/32/1441_2.png) [@wmakley](https://discourse.gohugo.io/u/wmakley)
#### Post date: [August 2, 2016, 4:20pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/10 "2016-08-02T16:20:22Z")

</div>

I finally got around to installing hugo from source, and yes I got the same error message `error calling index: index of untyped nil`

This would be a lot easier to debug if there were a way to get hugo to just print out the contents of all the structs. I am honestly just guessing, there has to be a better way.

---

<div class="post-metadata">

### Author: ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)
#### Post date: [August 2, 2016, 4:25pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/11 "2016-08-02T16:25:49Z")

</div>

> [@wmakley](#):
>
> Is it possible to list the members of a taxonomy in a shortcode?

I would say no, but I’m currently reworking this, so it will soon.

Watch this issue:

> <https://github.com/gohugoio/hugo/issues/2309>
>
> Just an issue tracking the work done in #2303

---

<div class="post-metadata">

### Author: ![wmakley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/wmakley/32/1441_2.png) [@wmakley](https://discourse.gohugo.io/u/wmakley)
#### Post date: [August 2, 2016, 4:28pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/12 "2016-08-02T16:28:26Z")

</div>

Thanks! By the way I understand that this isn’t what a shortcode is for, the issue is we have a one-off page that needs to have a lot of specific data on it. As far as I can tell, there is no way to create a one-off layout for a single page.

---

<div class="post-metadata">

### Author: ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)
#### Post date: [August 2, 2016, 4:38pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/13 "2016-08-02T16:38:48Z")

</div>

> [@wmakley](#):
>
> As far as I can tell, there is no way to create a one-off layout for a single page.

There is, but it isn’t very well documented.

Add it as a HTML file to /content with no front-matter, i.e. /content/one-off.html. It will not get any layout, but you should be able to list taxonomies etc.

---

<div class="post-metadata">

### Author: ![waddles](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/waddles/32/1270_2.png) [@waddles](https://discourse.gohugo.io/u/waddles)
#### Post date: [August 2, 2016, 9:26pm UTC](https://discourse.gohugo.io/t/listing-members-of-a-taxonomy-in-shortcode/3697/14 "2016-08-02T21:26:33Z")

</div>

> [@wmakley](#):
>
> I finally got around to installing hugo from source, and yes I got the same error message error calling index: index of untyped nil

Hmmm, it was working for me but I’m not sure I did a dry run so it may have been due to [Iterating over items in a taxonomy does not always work · Issue #2323 · gohugoio/hugo · GitHub](https://github.com/spf13/hugo/issues/2323)
