Multilingual rss feed

I’m trying to have the main rss feed located in /index.xml to ouput all the available languages.

So far the code I have is this:

{{ range first 50 (where (where .Data.Pages ".Params.options" "!=" nil) ".Params.options.unlisted" "!=" true)  }}

Only recently did I noticed that localhost/index.xml only returns the default version. If I want the Portuguese content I need to visit localhost/pt/index.xml.

Is it possible to have the following behaviour?

localhost/en/index.xml => English feed
localhost/pt/index.xml => Portuguese Feed
localhost/index.xml => PT + EN feed

If not, how can I include both languages in the range? I thought it was enough to replace .Data with .Site, but I was wrong.

Would try this first

    home                  = [ "HTML", "RSS"]

    MediaType             = "application/rss+xml"
    BaseName              = "index"
    suffix                = "xml"

my own template is _default/home.rss.xml

I have done it the same way for ATOM and JSON

Well I tried but the result is the same. And since part of the content has an unlisted option, I am forced to range over the content in rss.html

looked in my templates

{{ $r1 := where .Site.Pages "PublishDate" "gt" $start }}
{{ $r2 := where .Data.Pages.ByDate.Reverse "Section" "not in" (split .Site.Params.invisibleSections ",") }}
{{ range $r1 | intersect $r2 }}

Could this be an start for you?

1 Like

The trick to get all language pages is to range over .Site.AllRegularPages etc.


yes that works :slight_smile:

.Data.Pages however allows for a more versatile rss feed, per section and category. So I am going to let it as is, mark it as solved and move on.