Wordpress-seo: Sitemap error: error at line 2 column 6: XML declaration only allowed at the beginning of the document

Created on 11 May 2017  Â·  7Comments  Â·  Source: Yoast/wordpress-seo

Expected Behavior:

From the Yoast-plugin I chose XML-Sitemaps and there the link is given under "You can find your Sitemap here" (in my case: http://www.blog.lilleulven.com/sitemap_index.xml). When following the link I expected an XML page to come up with the structure of my blog.

Error:

Instead, I get the following error in Safari/Chrome:
"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."
In Firefox it is a little more detailed to:
"XML-Processingerror: XML- or Text-declaration not in the beginning of the enitity
Address: http://www.blog.lilleulven.com/sitemap_index.xml
Line Nr. 2, Column1:
^

How can we reproduce this behavior?

I assume by creating a sitemap from the plugin or else follow this link to the sitemap created by the Yoast plugin: http://www.blog.lilleulven.com/sitemap_index.xml

Can you provide a link to a page which shows this issue? http://www.blog.lilleulven.com/sitemap_index.xml

Technical info

  • WordPress version: 4.7.4
  • Yoast SEO version: 4.7.1
wait for feedback

Most helpful comment

Every page on your page (included sitemaps) contains empty line at the begin. (You can see HTML source) You should remove this line to fix sitemaps. You can try following steps:

  • Check your wp-config.php file for blank lines outside of <? and ?> bracketed sections.

  • Check your theme’s functions.php file for blank lines outside of <? and ?> bracketed sections.

  • One by one, disable plugins and revalidate until you isolate the one causing the problem ( How To Check For Plugin Conflicts )

Note that the final php ?> should be omitted from all PHP code files - modules, includes, etc. (eg. wp-config.php, functions.php, ...).

More instructions (related to first and second step) you can find on How_do_I_solve_the_Headers_already_sent_warning_problem Try to re-save file without BOM (eg. you can use Notepad++)

Hope that helps

All 7 comments

Thanks for reporting this issue. However, we're unable to reproduce this.

We've written an article about common sitemap errors which you can find here:
https://kb.yoast.com/kb/xml-sitemap-errors/

Unfortunately the link you have given, is not reachable.

Can you please inform us of the results?

Hi Caroline,

There has been some internet-hiccup making my website inaccessible earlier today. It is however fixed now, yet the error for http://www.blog.lilleulven.com/sitemap_index.xml http://www.blog.lilleulven.com/sitemap_index.xml persists (the link should be accessible now again). Unfortunately the error I am receiving is not part of your list (see attached screenshot).

Hope you can help me fix this error.

Best regards

Wiebke / Lille Ulven

Am 12.05.2017 um 10:31 schrieb Caroline Geven notifications@github.com:

Thanks for reporting this issue. However, we're unable to reproduce this.

We've written an article about common sitemap errors which you can find here:
https://kb.yoast.com/kb/xml-sitemap-errors/ https://kb.yoast.com/kb/xml-sitemap-errors/
Unfortunately the link you have given, is not reachable.

Can you please inform us of the results?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/Yoast/wordpress-seo/issues/7105#issuecomment-301017353, or mute the thread https://github.com/notifications/unsubscribe-auth/AbTSHiNsYTxHnkR8kEve_X6WFh91hlemks5r5BjcgaJpZM4NYCNP.

Every page on your page (included sitemaps) contains empty line at the begin. (You can see HTML source) You should remove this line to fix sitemaps. You can try following steps:

  • Check your wp-config.php file for blank lines outside of <? and ?> bracketed sections.

  • Check your theme’s functions.php file for blank lines outside of <? and ?> bracketed sections.

  • One by one, disable plugins and revalidate until you isolate the one causing the problem ( How To Check For Plugin Conflicts )

Note that the final php ?> should be omitted from all PHP code files - modules, includes, etc. (eg. wp-config.php, functions.php, ...).

More instructions (related to first and second step) you can find on How_do_I_solve_the_Headers_already_sent_warning_problem Try to re-save file without BOM (eg. you can use Notepad++)

Hope that helps

Thank you so much, @stodorovic your tip of omitting the final ?> did the trick for me.
Lots to learn for me, but I am enjoying it.

Good to hear, I'm closing as this is fixed :)

thanks @stodorovic checked my child functions, and it had the closing bracket, saved my day thnx a lot

Hello Guys also have them facing the same issue which I resolve with help of the below stuff as follows

*First watch full video then only proceed.

Video Tutorial to troubleshoot::

https://www.youtube.com/watch?v=PGathYQHHzk&ab_channel=ChykalophiaGroup

Article:: https://piotrkrzyzek.com/2010/07/05/wordpress-remove-blank-line-from-rss-feed-wordpress-error-on-line-2-at-column-6-xml-declaration-allowed-only-at-the-start-of-the-document/

Was this page helpful?
0 / 5 - 0 ratings