1

I'm trying to get my blog's RSS feed setup correctly. I'm running Hugo and deploying through Netlify. When I try to look at the .xml file for the page I'm interested in (or the .xml files for any of the pages for that matter), I get the following error message:

This page contains the following errors: error on line 2 at column 6: XML declaration allowed only at the start of the document Below is a rendering of the page up to the first error.

It seems to be a common problem, and all of the solutions I've read so far are centered on removing arbitrary white space that is added to the beginning of the line, which throws up this error. However, when I look at the source code for the page, I don't see any white space.

source code

I even pasted the source code in xmlvalidation.com, which said, yes, there is an error:

error message

I'm new to all this and don't know what to make of any of this. Any suggestions would be most welcome. Thanks!

anguyen1210
  • 513
  • 5
  • 21
  • There is an empty first line. It counts as whitespace, too. Remove it. – choroba Oct 11 '19 at 14:15
  • 1
    One cannot typically "see" whitespace. The solution is tricky but breaks down into the three basic possibilities listed in the canonical Q/A for this problem; see duplicate link. – kjhughes Oct 11 '19 at 16:02
  • 1
    (One of the three possible causes of the error message is multiple XML declarations, which appears to be the problem in your RSS XML.) – kjhughes Oct 11 '19 at 16:16
  • Just because the problem was whitespace for other people, doesn't mean that the problem was whitespace in your case. In your case, the problem is that there are two XML declarations. – Michael Kay Oct 11 '19 at 21:50
  • Thanks @kjhughes. I found the problem. When I copied over the [hugo RSS.xml template](https://gohugo.io/templates/rss/#the-embedded-rss-xml) for my site, I did not realize that the very first line in the box of code they provide should not be copied over (begins with, `{{ printf " – anguyen1210 Oct 12 '19 at 07:38

0 Answers0