Category page using incorrect Layout

I have a site with 3 categories. Articles in each category are stored in a folder of the same name. Sometimes, when I visit the category page URL, Hugo is using an layouts/learn/list.html instead of layouts/taxonomy/category.html. I have specified layout: "taxonony/category.html in the frontmatter of each page. Furthermore, when I run hugo serve in --disableFastRender mode this does not occur, but when I use hugo to build the site it occurs.

Why is this happening?

Folder structure



Hi there,

It’s easier to help if we can see your actual site code in a repo somewhere. Please have a read about Requesting Help

1 Like

Unfortunately, I cannot post the code, as it’s private. I think what may be causing the problem is that my categories are named identically to my folder names. However, I am directly specifying the layout in each frontmatter, so it should always be rendered using that Layout.

Yes, that would cause issues. Taxonomies, terms, and content sections have different .Kind values in Hugo. This affects the lookup order that Hugo uses to select which template to use to generate your pages. If you have /foo/ as taxonomy, and also as a section, then there will be a collision. Sometimes it will render as taxonomy, sometimes not. Have a read here: Hugo's Lookup Order | Hugo

1 Like

The issue was solved by changing the folder names. However, In each folder’s index file, i specified the layout in the frontmatter, but it wouldn’t be used.

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