How do you render an RSS feed on folder route

Hi, I’m in the process of migrating from Ghost to Hugo. On Ghost my RSS feed is on the route /rss/ without any file name or extension. I’d like to not break my RSS feed in the migration but can’t figure out how to get RSS to render in hugo with that URL.

I’ve tried creating the file /content/rss/_index.md with

+++
description = ""
draft = false
slug = "rss"
title = "RSS Feed"
type = "rss"
kind = "rss"
outputs = ["RSS"]

+++

Testing

And then in my theme having a /layouts/rss/section.xml file (I’ve also tried with single.xml, list.xml, and rss.xml) to render.

I’ve also tried adding an output format in my config.toml:

[outputs]
  rss = ["RSS"]

But the best result I’ve got is the /rss/ route rendering html in my site layout. I’ve got the RSS feed working on /index.xml but that’s not what I want. I don’t see a way to add a folder level redirect either.

Anyone know how to do this?

If your server/host supports it, create a 301 redirect from old to new.

you can define the RSS file in your config (here from config.toml)

[outputFormats.RSS]
    mediaType              = "application/rss+xml"
    baseName               = "feeds/feed.rss"
    rel                    = "alternate"
    isPlainText            = false
    isHTML                 = false
    noUgly                 = true

Set feed.rss to your old name!

Trying the baseName as rss, rss/, and /rss/ all result in a 404 for the /rss/ route. It’s looking for the file extension it looks like.

Hugo feeds don’t work without extensions. I also learnt that when I moved a WP site to Hugo. Just redirect the old URL to the new one.

1 Like

1st:

To get the right file from a directory, you must configure your http server.

ex in Apache, must adjust the right dir and file names!

<Directory "/var/www/html/rss">
    DirectoryIndex feed.rss
</Directory>

check DocumentRoot

2nd:

you must use the name of the generated rss file in the server config - or fit it in HUGO

PS

Im my hugo sample are 3 different feeds RSS/ATOM/JSON
take what you need

1 Like

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