[SOLVED] How to create RSS section custom output?

I want to make a custom RSS feed, with all posts from a certain section. Sounds like a good task for custom outputs, right?

So in my config.toml file I have:

[outputFormats]
    [outputFormats.SectionRSS]
        name = "SectionRSS"
        mediaType = "application/rss"
        isPlainText = true
        baseName = "index.xml"
        isHTML = false

I’ve made a stub content file at /content/mysection/rss-feed.md with this as its contents:

+++
outputs = ["SectionRSS"]
url     = "rss-index.xml"
layout  = "section-rss"
+++

And I’ve put the RSS layout file at /themes/theme2018/layouts/_default/section-rss.xml.

But nothing gets rendered. Where am I going wrong?


Done:

  • Read the output formats documentation multiple times.
  • Searched the forum with multiple queries.
  • Googled.
  • Tried all different kind of approaches.

Hugo Static Site Generator v0.40.3 windows/amd64 BuildDate: 2018-05-09T07:47:04Z
GOOS=“windows”
GOARCH=“amd64”
GOVERSION=“go1.10.1”

You shouldn’t manually put the “.xml” extension there. Hugo auto-suffixes the .Suffix from the associated MediaType (“application/rss” in your case, and the suffix is already defined to be “xml” for that).

The only thing different that you are doing than I am, for custom output for ATOM feeds, is that you are setting the custom layout using layout… but that should not be a problem.

Also, isPlainText is false for RSS feeds… and probably leave out the isHTML parameter.

1 Like

If I leave out isPlainText (so it defaults to false), it works. :slight_smile: Thanks!

Just wondering, what’s the most practical way to iterate over actual content pages?

I’m asking because my custom RSS feed also shows up in .Site.RegularPages, and that messes up all kinds of page collections (recent content, index file, random ‘read more’ list, sitemap, RSS feed itself, etc).