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?

TylerH
  • 20,799
  • 66
  • 75
  • 101
nathaneastwood
  • 3,664
  • 24
  • 41
  • 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 '18 at 21:59
  • I can open an issue if needs be – nathaneastwood Feb 26 '18 at 22:03
  • Now on GitHub: https://github.com/rstudio/blogdown/issues/266 – nathaneastwood Feb 27 '18 at 08:58
  • 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"): https://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 '18 at 15:08
  • Thanks @YihuiXie. I did see that link when I googled it but I asked here because I feel like this should be a feature – nathaneastwood Feb 27 '18 at 17:10
  • 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 '18 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 https://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 '18 at 18:52
  • 1
    Which can be redirected from a GH issue just as easily as here. – hrbrmstr Feb 27 '18 at 18:53
  • 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 '18 at 18:56

2 Answers2

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.

Alison Hill
  • 256
  • 2
  • 3
  • 1
    As of Hugo v0.58.2, this is no longer working. @Alison any ideas? – nathaneastwood Sep 17 '19 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. – nathaneastwood Sep 17 '19 at 17:36
  • Actually, that was incorrect. It is due to the issue described [here](https://stackoverflow.com/questions/57528205/blogdown-home-page-not-showing-toc-of-posts-any-more). 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. – nathaneastwood Sep 17 '19 at 17:56
  • did you happen to find a new solution by any chance? – Tlatwork Jul 12 '20 at 07:00
  • 2
    @Tlatwork I didn't. In the end I just locked my version of Hugo to a version prior to this update. – nathaneastwood Jul 20 '20 at 12:13
  • I had to use ```{{ printf `<![CDATA[%s]]>`.Content | safeHTML }}``` so that the xml was safe. – troh Jun 02 '21 at 02:00
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

orrymr
  • 2,264
  • 4
  • 21
  • 29
  • 1
    thats a great idea. Unfortunately, I attempted to do so but failed. Do you have any hints? https://stackoverflow.com/questions/65447256/get-blogdown-on-r-blogggers-for-hugo-goa – Tlatwork Dec 25 '20 at 10:29