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:
In your site’s config.toml
, place the following:
[outputs]
home = ["HTML","FEED"]
[mediaTypes]
[mediaTypes."application/rss"]
suffix = "xml"
[outputFormats]
[outputFormats.FEED]
mediatype = "application/rss"
baseName = "feed"
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.
No, that isn’t how I would do it.
Remove all but this:
[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?
The question was “How can I change the RSS URL?” A simple question should not need a two page manual.
A simple question should also have a related answer. Here is my question, again:
I’m asking about my mistake so that I can make it easier to grok in the docs. This requires I understand it better myself.
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.
Ok, I apologize if I’ve missed something here. What I’ve done is added the following to my site’s config.toml
:
[outputFormats]
[outputFormats.RSS]
mediatype = "application/rss"
baseName = "feed"
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:
[outputs]
home = ["HTML","FEED"]
[mediaTypes]
[mediaTypes."application/rss"]
suffix = "xml"
[outputFormats]
[outputFormats.FEED]
mediatype = "application/rss"
baseName = "feed"
And then generate the site, again with the /layouts/index.feed.xml
in place, I do get a /feed.xml
generated.
Am I missing something here?
Yea, I posted it without testing it. Seems like that to redefine the RSS
, it must also be in a outputs list, i.e.
[outputs]
home = [ "RSS"]
It seems like the default list (when not outputs are set) gets its definition from the built-in list, which is a little surprising, will fix that.
If I only include in my config.toml
the following chunks:
[outputs]
home = [ "RSS"]
[outputFormats]
[outputFormats.RSS]
mediatype = "application/rss"
baseName = "feed"
I wind up with no /index.html
, only a /feed.xml
. I had to instead specify:
[outputs]
home = [ "RSS", "HTML"]
[outputFormats]
[outputFormats.RSS]
mediatype = "application/rss"
baseName = "feed"
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”.
I am trying to change the url to my RSS feed to be:
/news.rss
I’m using the following configuration:
outputs:
home: ["HTML","RSS"]
mediaTypes:
"application/rss":
suffix: "rss"
outputFormats:
RSS:
mediatype: "application/rss"
baseName: "news"
which does generate the /news.rss file - however, I cannot figure out where to place/name the template for this.
I have tried:
- layouts/index.xml
- layouts/news.rss
- layouts/index.news.rss
- layouts/news.xml
- layouts/index.rss
to no avail. If I comment out the config above, restoring RSS functionality to the defaults, then my template at:
layouts/rss.xml
works fine.
What am I missing?
Try layouts/rss.xml
Thanks, but no dice - this is ignored if I have that configuration (above) set.
@paulwalk What if you add disableRSS: true
or disableRSS = true
in your config.yml
or config.toml
, respectively?
I just tried setting disableRSS: true
to my config.yaml file. With this set, when I go to the RSS URL I get a 404. I imagine this is expected behaviour?
For those using config.yml, here’s what I added to the file.
outputFormats:
RSS:
mediatype: "application/rss"
baseName: "feed"
Worked for me using Hugo 0.80.0. The RSS feed was renamed to feed.xml