How to get taxonomy tag data outside of taxonomy templates

I am trying to list tags on a page on that is not using the layouts/_default/terms.html template.

I am trying to Use .Site.Taxonomies Outside of Taxonomy Templates and have that it also return data that is in our tag.yml file

Each tag should have the:

  • id (slug)
  • display_name
  • count
  • summary (this is additional data)

This page in the docs helped me to call the taxonomy I needed outside the terms.html page, but I am unclear on how I can access the tag data that we have in our tag.yml data file.

It looks like $.Site.Taxonomies.tag does not have the tag data, just the post/page data associated with each tag. Is that correct?

Here is what I have tried so far…

{{/* Ranges through all the tag data — tag name + posts */}}
{{- range $tag_name, $tag_posts := index $.Site.Taxonomies.tag -}}

  {{/* $tag_data == trying to look up the data for a tag,
  but unfortunately, I only have the display_name, not the key */}}
  {{- $tag_data := (index $.Site.Data.tag $tag_name) -}}

  {{/* Tag Name | # of posts associated with that tag | tag display_name */}}
  <p>{{ $tag_name }} | {{ $tag_posts.Count }} | {{ $tag_data.display_name }} | (tag summary)</p>

{{- end -}}

Any advice?

Yes. In order to get the full Front Matter of your term you would need to use .Site.GetPage

Not sure what key you are talking about? The key from the tag.yml?

Any reason why you guys are not using Front Matter here?
You can add Front Matter to any taxonomy terms by creating a file and populate it with FM in the content dir. So if your tag is art:

# content/tags/art/`
id: 23
display_name: Art
count: #you could dynamically retrieve this :) 
summary: Lorem ispsum
And a content why not...

@regis Interesting. I am going to test to see if by moving our tags out of a single file and into separate data files will improve my ability to fetch data about each tag.

Oh wait, I see what you were talking about — this: