[FIXED] Single.rss.xml does not work?

Hi there !

New here and successfully launched few blogs on hugo already.

I am having a weird problem with RSS templates: single.rss.xml on my templates folder does not seem to be read at all (hugo uses the default RSS template), I know it’s stranger to want to have a RSS from a simple posting but single.ANYTHING.ANYTHING seems to work ok (single.amp.html for instance), it’s just that the RSS for some reason does not want to work and it reverts back into the default RSS. I have tried placing it in layouts/_default/ and mostly everywhere with zero luck and I am honestly puzzled about this behavior.

So my questions are:

  • Is this intended? Is there any way I can specify an XML template for an RSS feed from a single post? I can’t seem to be able to find any information on this online.
  • Is there a way to debug this ? Any way to make hugo verbose so it will let me know what’s the problem exactly ?

Thanks, I really appreciate your responses.

you can use the option --debug with hugo. Best to send the output to a file.

hugo -b http://localhost:1313 --debug --templateMetrics --verboseLog > debug.log

In frontmatter you can use the layout param to select wanted templates.

My best guess is you have not enabled RSS for regular pages. This is default off.

1 Like

thanks @bep! I believe RSS are enabled. The problem is not that RSS won’t render, is that it’s using _internal instead of _default

page = [ "HTML", "RSS" ]

isPlainText = true
suffixes = ["xml"]

mediatype = "application/rss"
baseName = "index"

Thanks ! @ju52, I am investigating what’s going on, on debug.log I have (redacted) :

DEBUG 2019/07/12 13:35:36 Add template file: name "_default/single.rss.xml", baseTemplatePath "", path "_default/single.rss.xml"

then in template metrics I can see that template is being accessed:

   264.198192ms     207.376µs   27.690206ms   1274  _default/single.rss.xml
1.383360017s     613.191µs   99.197599ms   2256  _internal/_default/rss.xml

although hitting that URL (http://localhost:1313/category/post/index.xml) returns not my template at single.rss.xml but _internal/default/rss.xml

I don’t think I can tweak this with Front Matter / Layout (since post/index.html should also work with regular HTML templates) , I may be wrong. As I mention, I am still new at hugo.

@bep in older debug logs - I could find what hugo is looking for and missed. Is this gone? Could help to solve such problems.

single.rss.xml is used for single items. post/index.xml is a list page and uses the list template. you explicitly tell Hugo to only parse single items with your template, for the rest it falls back on the internal templates. Rename it from single.rss.xml to rss.xml and see what happens? Or make a copy list.rss.xml to apply only for list pages.

you explicitly tell Hugo to only parse single items with your template

No idea if I follow. Explicily how ?

Rename it from single.rss.xml to rss.xml and see what happens?

Nothing, rss.xml == list.rss.xml , single items are still parsed by _internal.


No idea, I looked at that too, it looks like it’s gone. (I keep thinking the impossibility of simple.rss.xml is a bug)

By calling it single.rss.xml :wink:

Where exactly is the md-file you want to transform? You wrote before http://localhost:1313/category/post/index.xml does not use your template - is the file in /content/category/post/index.md? You might want to put your template then in /layouts/categories/rss.xml.

But if just using _default/rss.xml should have done the trick and be used for all items… strange.

I’ve tried (placing single.rss.xml and rss.xml literally everywhere in the lookup order) and this is really weird, it doesn’t work.

I am going to try to spend a good chunk of time tomorrow on this, I think it may be a bug and I may be able to dig in the code, but in the meantime, could anybody try to replicate this ?

I just tried, still nothing, going straight to the default RSS template :frowning:

Fixed. Do not ask me why, but I removed all old RSS templates, put only one on _default/ and it works wonders now. Seriously, I have no idea what was going on, but this is how I made it work :

find . -iname "*rss*"

(It sounds like a serious case of ‘turn it off and back on to fix it’ but I was losing my mind)

Thanks @ju52 @davidsneighbour and @bep you guys are awesome. :slight_smile:

please mark the right reply as solution :slight_smile: