# Using the right template

**URL:** <https://discourse.gohugo.io/t/using-the-right-template/3253>\
**Category:** support\
**Created:** [May 1, 2016, 8:09pm UTC](https://discourse.gohugo.io/t/using-the-right-template/3253 "2016-05-01T20:09:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![StarfallProjects](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/starfallprojects/32/3210_2.png) [@StarfallProjects](https://discourse.gohugo.io/u/StarfallProjects)\
**Post date:** [May 1, 2016, 8:09pm UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/1 "2016-05-01T20:09:31Z")

</div>

Another newbie question (how many of these can I have before someone blocks me?)

I have a simple theme. In addition to the default templates (index, single, list) I have created a tags.html and put it in the \_default folder.

Then in my content, I have two folders:  
posts  
tags

The intention is that everything in posts should use the single.html template, which it does.

However I want everything in tags to use the tags.html template. Which it doesn’t.

I understood from the help docs that Hugo would look for the template that matches the name first, and then fall back on single if nothing matching was found?

However, judging by point 14 on this page, it has to be done manually: [https://medium.com/@jeffmcmorris/tips-and-tricks-for-building-a-theme-in-hugo-4806bdd747d7#.3gnrz68k6](https://medium.com/@jeffmcmorris/tips-and-tricks-for-building-a-theme-in-hugo-4806bdd747d7#.3gnrz68k6)  
(@delay brilliant post by the way)

Can anyone clarify if there should be some automatic way, or if I need to use the technique at that link?

Related question: under what circumstances would it fall back to list rather than single?

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [May 1, 2016, 8:59pm UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/2 "2016-05-01T20:59:01Z")

</div>

First question is why you are creating a content folder for tags? Have you looked into taxonomies. Once you answer that, maybe I can help. Would you mind showing us the rest of your source organization as well?

Off the bat, I’m thinking you can just create a template at `layouts/tags/single.html`, but you are probably doing more work than necessary since Hugo has built-in support for taxonomies.

---

<div class="post-metadata">

**Author:** ![StarfallProjects](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/starfallprojects/32/3210_2.png) [@StarfallProjects](https://discourse.gohugo.io/u/StarfallProjects)\
**Post date:** [May 1, 2016, 9:00pm UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/3 "2016-05-01T21:00:49Z")

</div>

So, I have tags appearing on my index page, which link through to . . . nothing, unless I create a landing page for them.

All my source code (theme and content) can be found here: [https://www.dropbox.com/sh/mg2jcixdmbjzjhr/AACncH4V4\_LCeH3L4i\_L5xsJa?dl=0](https://www.dropbox.com/sh/mg2jcixdmbjzjhr/AACncH4V4_LCeH3L4i_L5xsJa?dl=0)

Edit for correct link

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [May 2, 2016, 3:31am UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/4 "2016-05-02T03:31:06Z")

</div>

@StarfallProjects

Alrighty, so a few things:

1. I know Dropbox seems very convenient right now, but ultimately I’d recommend learning about a basic git flow and putting your code into a proper DVCS (version control). I’m a fan of [Atlassian’s tutorials](https://www.atlassian.com/git/tutorials/comparing-workflows/), but you’ll ultimately probably end up using GitHub for your hosted git solution. This is going to make it easier for you to revert to previous versions, run continuous deployment/integration, share code with collaborators (including the good folks in this forum), etc. I know you said you’re a newb, and it’s a lot to take in. If you have the resources, I’d also recommend [_Git for Humans_](https://abookapart.com/products/git-for-humans) (or any other book in the ABA series).
2. [Read the documentation on taxonomies](http://gohugo.io/taxonomies/overview/). Here is the first step to fixing your `config.toml`:

```auto
theme = "chipButtyBellsOn"
baseurl = "http://replace-this-with-your-hugo-site.com/"
languageCode = "en-uk"
title = "My New Hugo Site"

[taxonomies]
  tag = "tags"

```

1. Now, in `layouts/_default/terms.html` use whatever header and footer you want to keep across all your pages, and add something like the following. I’m not saying you need to use this, but it will give you an idea of how taxonomies work:

```auto
<ul class="tags">
	    {{ $data := .Data }}
	    {{ range $key,$value := .Data.Terms.ByCount }}
	    <li class="site-tag">
			<a href="/{{ $data.Plural }}/{{ $value.Name | urlize }}">{{ replace $value.Name "-" " " | upper }} ({{ $value.Count }})</a>
			</li>
	    {{ end }}
</ul>

```

Hope that helps.

---

<div class="post-metadata">

**Author:** ![StarfallProjects](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/starfallprojects/32/3210_2.png) [@StarfallProjects](https://discourse.gohugo.io/u/StarfallProjects)\
**Post date:** [May 2, 2016, 10:23am UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/5 "2016-05-02T10:23:54Z")

</div>

Thanks for this!

I am using git for the themes themselves, just not the whole site. [https://github.com/StarfallProjects/chipButtyBellsOn](https://github.com/StarfallProjects/chipButtyBellsOn)

I will give your example a try. I had already read about taxonomies but was still a bit fuzzy about them.

I think the problem is, the documentation assumes a certain level of knowledge (which is fair enough, most people coming here will have that knowledge). I’ve never used anything like this before - never used Jekyll, never even got into Wordpress or such like. So I need to start with the really basic level of ‘what is a taxonomy and why would you use one’ 😛

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [May 2, 2016, 4:53pm UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/6 "2016-05-02T16:53:20Z")

</div>

@StarfallProjects Here is an example of how to call those tags on your homepage (and have them link to the appropriate page) once you’re comfortable with using taxonomies:

```auto
<ul class="site-tags">
    {{range $name,$taxonomy := .Site.Taxonomies.tags}}
        <li><a href="/tags/{{$name}}">{{replace $name "-" " "}}</a></li>
    {{end}}
</ul>

```

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [May 2, 2016, 4:54pm UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/7 "2016-05-02T16:54:53Z")

</div>

> [@StarfallProjects](#):
>
> So I need to start with the really basic level of 'what is a taxonomy and why would you use one

I think the Hugo docs in this regard are better than most for SSGs:

> **[Taxonomies](https://gohugo.io/content-management/taxonomies/)**
>
> Hugo includes support for user-defined taxonomies.

---

<div class="post-metadata">

**Author:** ![phi](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@phi](https://discourse.gohugo.io/u/phi)\
**Post date:** [May 3, 2016, 9:58pm UTC](https://discourse.gohugo.io/t/using-the-right-template/3253/8 "2016-05-03T21:58:48Z")

</div>

@rdwatters Thanks for sharing a link to this tutorial! Helped me alot!
