Add RSS feed to section in Hugo

Posted on

I was experimenting with adding a new section in Hugo, and adding a RSS feed that only contained content from that specific section. I also wanted to create the new RSS feed in the /feeds directory and not in the standard section directory.


Make sure there's a content folder, in this case content/newsection.

Add a new output format:

outputFormats:
    til:
        mediaType: "application/rss+xml"
        baseName: "../feed/newsection"
        notAlternative: true

This new format will put the new file at baseName, relative to the currect section path. notAlternative means that no default feed file will be created (in this case in /newsection/feed). The mediaType is already defined by default.

Add the new output format to the correct output:

outputs:
    section:
        - html
        - newsection

Finally create a template for the new feed at layouts/_default/section.newsection.xml. I don't understand why the file has to be in that specific directory or have that specific name, but it works.

If I tried to put the new template anywhere else I would get this message:

WARN  found no layout file for "til" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.