# Question about template lookup order

**URL:** <https://discourse.gohugo.io/t/question-about-template-lookup-order/33664>\
**Category:** support\
**Created:** [July 1, 2021, 8:06pm UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664 "2021-07-01T20:06:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradbice](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bradbice/32/14162_2.png) [@bradbice](https://discourse.gohugo.io/u/bradbice)\
**Post date:** [July 1, 2021, 8:06pm UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/1 "2021-07-01T20:06:33Z")

</div>

The theme layout lookup rules are very confusing to me. Why is this an issue? I have:

```auto
type: team-stats

```

in my `content/nba/team-stats/warriors.md` file, and the `single.html` is under `layouts/team-stats`. According to the lookup rules, shouldn’t the warriors page be the only one using this template?

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [July 2, 2021, 2:04pm UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/2 "2021-07-02T14:04:10Z")

</div>

Put the file under `layouts/_default/team-stats.html` and call the frontmatter `layout: team-stats`. I am pretty sure you mix up something if you expect the setup above to work.

---

<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:** [July 3, 2021, 3:34am UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/3 "2021-07-03T03:34:27Z")

</div>

> [@bradbice](#):
>
> shouldn’t the warriors page be the only one using this template?

Can you clarify your question:

* * *

Do you mean that other pages are also using this template?

According to the lookup rules, this template will apply to anything with single pages of type `team-stats`, so if you have `content/team-stats/foo.md` that will also use this template.

* * *

Or do you mean that `nba/team-stats/warriors.md` is **not** using this template file when it should?

If this is the case, then something more specific is being used instead, because it should work as described. Unless we can see the rest of your code, we can’t say what that is.

---

<div class="post-metadata">

**Author:** ![andreseduardop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/andreseduardop/32/25434_2.png) [@andreseduardop](https://discourse.gohugo.io/u/andreseduardop)\
**Post date:** [July 3, 2021, 8:05pm UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/4 "2021-07-03T20:05:54Z")

</div>

There are several ways to make it work.

I suggest to do it by defining the layout in the Front Matter.

> **[Hugo's Lookup Order](https://gohugo.io/templates/lookup-order/)**
>
> Hugo searches for the layout to use for a given page in a well defined order, starting from the most specific.

---

<div class="post-metadata">

**Author:** ![bradbice](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bradbice/32/14162_2.png) [@bradbice](https://discourse.gohugo.io/u/bradbice)\
**Post date:** [July 9, 2021, 4:51pm UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/5 "2021-07-09T16:51:46Z")

</div>

I mean that I only have the one content directory called `team-stats`: `content/nba/team-stats`

Also, the content files in that directory are the only files calling `type: team-stats` in the front matter.

The issue I’m having is that using something like

```auto
{{ partial (printf "symbols/nba/_%s.svg" .Params.nickname) }}

```

gives me this error:

```auto
error calling partial: partial "symbols/nba/_%!s(<nil>).svg" not found

```

which was explained that any pages calling this template (there is only 1, `warriors.md`) need to have `nickname` applied in their Front Matter. They all do, like this:

```auto
---
title: Golden State Warriors
nickname: warriors
type: team-stats
---

```

---

<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:** [July 10, 2021, 6:53am UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/6 "2021-07-10T06:53:59Z")

</div>

Do you have your code in a repo somewhere? Cloning is easier than trying to replicate your setup.

---

<div class="post-metadata">

**Author:** ![bradbice](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bradbice/32/14162_2.png) [@bradbice](https://discourse.gohugo.io/u/bradbice)\
**Post date:** [July 10, 2021, 1:56pm UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/7 "2021-07-10T13:56:32Z")

</div>

I actually found an errant content file that I had set to `type: team-stats`, which did not have `nickname` set in the Front Matter, embarrassingly.

All is well now. Thanks everyone for the help and support.

---

<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:** [July 12, 2021, 1:57pm UTC](https://discourse.gohugo.io/t/question-about-template-lookup-order/33664/8 "2021-07-12T13:57:17Z")

</div>

Closed on July 12, 2021, 1:57pm UTC

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