Question about template lookup order

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

type: team-stats

in my content/nba/team-stats/ 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?

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.

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/ that will also use this template.

Or do you mean that nba/team-stats/ 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.

There are several ways to make it work.

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

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

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

gives me this error:

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

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

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

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

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.

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