Bummer. I guess I’ll just use a post-build script to move the file where I want it. I don’t want RSS feeds generated for my tags either so I can have a script delete those as well.
It’d be nice to have a little more control over this in the future. Do you have any plans in this area?
Is there any way to do this yet? By default Hugo generates RSS at “http://baseurl.com/index.xml”, but when migrating TO Hugo, it’d be nice to avoid having to have everyone re-subscribe when the old URL is, for example, “http://baseurl.com/feed.xml”.
What you want is possible (which is a different requirement than the thread starter).
I would suggest you re-define the RSS output format (look at the docs). There is also the RSSUri setting, but that will be deprecated and removed sone.
Sorry, it looked like the same answer I was looking for, but the Output Formats documentation is very confusing, as it’s blended with Media Types and has no actual usable examples. Are there any such examples I could take a look at?
Media types and output formats are very much connected. Documentation will eventually improve, examples will come – for now I can only hint that you need to create a RSS output format definition with feed as the baseName.
@codydh I have been toying around with custom outputs and figured out a way to create a feed.xml for the homepage. I’ll delimit the steps here—I need to improve the documentation as well—but this should provide enough insight to get you going on doing the same for your individual sections, etc. Keep in mind this is my first time using this features, so YMMV:
Notice how you define that the Kind of home specifically outputs HTML (default behavior) as well as FEED. You need to declare these explicitly, and although they are all uppercase, output formats are case insensitive.
You can then create your layout for the homepage RSS feed at layouts/index.feed.xml. When your site builds, it will output whatever templating you put inside of this layout at codydhsite.com/feed.xml. For your use case, section is also a Kind, so you could create a similar layout/template at layouts/_default/section.feed.xml and then set the section kind accordingly in your site’s configuration file…
HTH.
I’m looking to @bep to confirm if I’m on the right track since this is what I’ve figure out for potential improvements to the docs in this area.
[outputFormats]
[outputFormats.RSS]
mediatype = "application/rss"
baseName = "feed"
```
The above should _redefine_ the built-in output format `RSS`, and then you don't have to add anything else.
Is my issue that I treated RSS like a fully custom output rather than one of Hugo’s built-in media types? So, for example, if @codydh wanted to make codydhsite.com/mycrazyfile.onetwothree, that would require additions similar to the above?
Your answer worked – and is of course relevant when you want to create a custom feed (say you want both Atom and RSS … or whatever); but for this particular question it felt a little too much.
I tried this alone, as well as adding the stock rss template from the documentation to a file index.feed.xml. However, the only thing that’s generated is the usual /index.xml.
If I use the full config.toml additions that @rdwatters had suggested:
Which seems to do the job! The only thing now is that {{ .Site.RSSLink }} still winds up pointing to /index.xml, but this can obviously be worked around.
The RSSLink is unfortunate (and I make a note of that, you can maybe work around that by setting the RSSUri), but I would recommend having a look at the OutputFormats and AlternativeOutputFormats when creating links to “other formats”.