Custom RSS Template for a specific category

Hello,

I’m trying to override the RSS template for a specific category “foo”. No matter where I put this custom template or name the file, it doesn’t seem to work. I was able to override the template for all categories by using this :

layouts/categories/rss.xml

So after I tried several combinations but nothing seems to work:

layouts/categories/foo/rss.xml
layouts/categories/foo/index.xml
layouts/categories/foo.rss.xml
layouts/categories/foo.index.xml

I searched the forum and documentation but I didn’t find the right answer.

content/categories/foo/_index.md

+++
title = 'Foo'
date = 2025-02-09T08:21:25-08:00
draft = false
layout = 'foo/list'
+++

structure

layouts/
├── _default/
│   ├── baseof.html
│   ├── home.html
│   ├── list.html
│   └── single.html
└── categories/
    └── foo/
        └── list.rss.xml

When rendering the HTML output format, it won’t find a matching layout “foo/list” so it will fall back to the standard lookup order (layouts/_default/list.html in this case).

1 Like

Thank you, it did the trick.

Do you know why we have to explicitly set the layout in the _index.md file ? I would have thought that having only a layouts/categories/foo/list.rss.xml file would have the same effect.

layouts/<taxonomy>/<term>/list.html is not in the lookup order for term templates. I agree that would handy and intuitive. Would you mind creating a proposal here?

There may be some un-documented way to handle this, but I’m drawing a blank.

The table in Template lookup order | Hugo would have been better if there was an actual term (e.g. “blue”) used to generate it.

So… is there a way to target my-taxonomy/my-term? I couldn’t make it work.

No, it isn’t. I assumed it was, but I checked, it’s not.

I created this proposal GitHub · Where software is built

2 Likes

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