28

I generate my blog using blogdown, but when I have tried to submit it to R-Bloggers it is not accepted because my feed returns the following error:

This XML document is invalid, likely due to invalid characters.
XML error: Undeclared entity error at line 6, column 35

Apparently the feed for my website does not contain the full RSS content. How do I get it to hold all the content?

9
  • 6
    I'm voting to close this question as off-topic because it belongs as an issue on the blogdown github site.
    – hrbrmstr
    Feb 26, 2018 at 21:59
  • 26
    @hrbrmstr I wonder if you really understand this question. Have you actually tried to build a website using Hugo and blogdown? I don't think this is off-topic, because it is a valid Hugo question (not directly relevant to blogdown). You may say it is a duplicate (of which the answer could be easily found by a Google search "hugo rss full content"): discourse.gohugo.io/t/full-text-rss-feed/8368 but it is definitely not off-topic, or belongs to the blogdown repo on Github. I believe it is better to push a question from a single maintainer to the community than the other way around.
    – Yihui Xie
    Feb 27, 2018 at 15:08
  • 1
    I don't appreciate the condescending tone @YihuiXie. And, if the issue is with a package, then my own, 100% OK opinion is that issues are totally great ways to resolve them (since I also author packages). And, 5 upticks on my comment somewhat vindicate that.
    – hrbrmstr
    Feb 27, 2018 at 18:52
  • 14
    I don't disagree that it should be a feature. It should be a Hugo feature instead of blogdown; blogdown does not have anything to do with Hugo templates (RSS templates in this case). If it has to be filed to a Github repo, the Github repo should be github.com/gohugoio/hugo instead of blogdown. I understand that it was me who introduced Hugo to blogdown users, so I have some responsibility on my shoulders to deal with pure Hugo questions. I'm fine with that. What I'm not fine with is that people close valid Hugo questions and force users to go to the wrong repo to ask questions.
    – Yihui Xie
    Feb 27, 2018 at 18:52
  • 14
    @hrbrmstr I apologize if you feel the tone was condescending. I didn't mean it. I was merely questioning what made you believe it was an off-topic question and belonged to the blogdown repo on Github. It is a question related to programming. It is not a bug of blogdown. It is definitely not practical for me to answer all Hugo questions. If you author a package that uses an upstream library, I believe you cannot answer all questions related to the upstream library, either.
    – Yihui Xie
    Feb 27, 2018 at 18:56

2 Answers 2

24

In the Hugo documentation (https://gohugo.io/templates/rss/), they provide the embedded RSS xml file that currently "ships with" Hugo. According to the docs, a section’s RSS will be rendered at /SECTION/index.xml (e.g., http://spf13.com/project/index.xml). So for your posts, it would be http://spf13.com/post/index.xml.

The key line in the built-in RSS xml file is this one:

<description>{{ .Summary | html }}</description>

From this discussion (https://discourse.gohugo.io/t/full-text-rss-feed/8368/2), it looks like you want to change what goes in the description tags from .Summary to .Content. Here is an example blog post where the author implemented this change: https://randomgeekery.org/2017/09/15/full-content-hugo-feeds/

So you would change that one line in the Hugo RSS xml to:

<description>{{ .Content | html }}</description>

The full rss.xml file should live in your layouts/ folder, with that one line changed.

It does look like there are other options you could test, like working with output formats in your config.toml file (https://github.com/gcushen/hugo-academic/issues/346; https://gohugo.io/templates/output-formats/) and referencing your RSS in your header.html (https://gohugo.io/templates/rss/), but changing .Summary to .Content should address your issue.

6
  • 1
    As of Hugo v0.58.2, this is no longer working. @Alison any ideas? Sep 17, 2019 at 16:42
  • Ok, I think have figured this out. In your themes/ folder there is a /layouts/_default folder. In there, you need your rss.xml file. This then generates the public/post/index.xml file. This is the one you need to contain the full content. Sep 17, 2019 at 17:36
  • Actually, that was incorrect. It is due to the issue described here. Essentially because of this new "Posts" page introduced by Hugo and I haven't quite figured out yet how to select the content from the posts and not the "Posts" page. Sep 17, 2019 at 17:56
  • did you happen to find a new solution by any chance?
    – Tlatwork
    Jul 12, 2020 at 7:00
  • 2
    @Tlatwork I didn't. In the end I just locked my version of Hugo to a version prior to this update. Jul 20, 2020 at 12:13
0

This seemed to work for me...

create a directory in your layouts folder called tags. So you should have this folder structure:

<your_base_directory>/layouts/tags

(this isn't the layouts directory in the themes directory).

Then create a new file:

<your_base_directory>/layouts/tags/rss.xml

Then paste this into your newly created rss.xml

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.