I’ve defined a “/layouts/taxonomy/category.html” layout that is used by all the categories.
Now, I want to have a different layout for one of my category - Kotlin.
How can I achieve this? I tried defining a layout in “/layouts/taxonomy/kotlin.html”, but this layout is not picked up by hugo.
I also tried specifying “layout: kotlin” in the front-matter of “/content/categories/kotlin/_index.md” file but the layout is still not picked up by hugo.
Here is how the categories section look like in the content directory -
content
categories
java
_index.md
spring
_index.md
kotlin
_index.md
The layouts for taxonomy are -
layouts
taxonomy
category.html
kotlin.html // I want this layout to be used for Kotlin category
You’d get more help if you post a link to the repo, or if you can’t, make a small demo site with the options from your config and the content in question. The reason is there are many components that can override or interfere with templates, so we need to see them all to troubleshoot.
@callicoder after reviewing the docs, I am not sure you can call a template for a specific category. I am sure someone will come along and confirm or deny that shortly.
You can define a different layout for /category/koitlin/ with a hack.
In your /_default/list.html define your layout like so:
{{ if eq .URL "/category/koitlin/" }}
.......Layout here......
{{ end }}
I have been berated for this hack in the past (see here) but this the only way that I have found to work in a use case like yours. And since this is for just one taxonomy term I can’t see harm in using it.