Search code examples
rxmlrsshugoblogdown

How do I get my blogdown blog on R-Bloggers?


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?


Solution

  • 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.