With a layout ./layouts/products
, How to create a term template page for it? Because the list.html in it is not inherited (inherits default instead) and the term template is ignored. Ideally, I would like the section and terms page to share the template but create a different one for taxonomies.
Is your ./layouts/products
a folder or a file? That’s not clear.
Think of it from a different perspective - your content. Does your content folder have a folder called products
, and are your products in it? We call that section
and in that case, you could “just” have the following files in layouts:
layouts/products/list.html - for list pages
layouts/products/single.html - for single pages
layouts/products/term.html - for term pages
layouts/products/taxonomy.html - for taxonomy pages
And so on.
If you can’t work with a single folder in the content root for your products, then keep the concept of the content type (layouts/products with templates inside) and add:
type: product
To your frontmatter for each product. This way, you override the default templates.
A folder obviously.
And to answer your question, I have the exact folder structure you shared, but the term pages are defaulting to the default list page and I did not want to duplicate the code for list and term. I will give the Template lookup order | Hugo another look.
From the lookup order, taxonomies and terms only inherit layouts from categories, category, term or taxonomy folders in layout. If those are missing, they fall back to the default folder.
Now this makes more sense.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.