XML sitemap error

Hey guys,

Getting this error: error on line 1 at column 8: XML declaration allowed only at the start of the document

on my url allayurveda.in/sitemap.xml

I don’t get this error when I switch to another theme. Please help.

Hi There,

Thanks for writing in!

Can you please tell more about the issue, how you have implemented the feature as the theme does not have a sitemap.xml feature. Let us know the plugins or code you have used for it so that we can investigate on it.

This is something outside of our support scope but we will do our best to find the pointers that can help you, if you could post your login details in a secure note so that we can have a look.

Thanks

Hi Basanta,

I’m using this plugin: https://wordpress.org/plugins/google-sitemap-generator/

Earlier, I was using Yoast SEO plugin but even that was giving me same error. I’m adding the login info under a secure note on reply to my original post for your reference.

Hey @sandeepbali,

Though Pro does introduce new line spaces before the HTML Doctype which is likely the cause of the XML issue, it is expected that your HTML output must be optimized. That is made possible using optimization plugins that minifies HTML or by contacting your web host if it’s possible they can set an htaccess rule that will remove new line spaces in HTML.

In some host, this comes out of the box. For example, my local dev site outputs the spaces above the doctype but this does not happen in my online dev site because the host removes new line spaces out of the box.

Regretfully, we could do nothing for this case.

Thank you for understanding.

Hi @christian_y,

I tried the way you asked me to do and optimized html code but still there is a white space coming.

I discussed the same with host provider but they told it will be resolved by you guys only. Please help us with solution as it is creating alot of problems.

Thanks,

Hi @sandeepbali
I am another user which had this issue for a long time, this problem, whichever reason it comes from, can be solved by the plugin in charge of building the xml that should be executing some cleanings before building it.

All in one SEO solved my issue since up to 3 other plugins was unable to do it. In case you don’t want to use this plugin, @christian_y might be on the right approach by suggesting you to minify html.
For this, in my website I also use Fast Velocity Minify, you can minify everything, or just html, and even strip the comments from the output.
Try different combinations until the page stop breaking (minifying sometimes breaks your page) and the xml is working properly. Remember, in each modification, delete all caches, including your browser to be sure you are watching the most updated version of your website.

Hope this helps

Hey @soportex

Thanks for the informative response. I tried using various various HTML Minify plugins, including Fast Velocity Minify as recommended by you, and it is able to remove empty line breaks above the html doctype declaration, but it is still leaving behind some empty white space just before the Doctype.

I can’t use All in one SEO as my SEO is already configured on the Yoast plugin that I’m using. Any other ideas?

Thanks.

1 Like

Exactly, the reason I leave Yoast was because i had this issue with it.

From here i don’t know what else you can use. Normally the great error comes from whitespaces in Php documents that has outside the tags of php.

For example, a small xfile.php that contains

<!--  <- this is a whitespace, probably computed as html -->
<?php ... 
?>

It could be this theme, or any other plugin you are using, and it can be solved by the xml builder if they are properly written, that’s why i offered the SEO plugin before.

Hope you find a way with this issue.

Thanks for chiming in and sharing your thoughts, Ignacio.

@sandeepbali, regretfully, I have no more suggestions. I tried Autoptimize to minify the HTML and it eliminated all whitespace above the Doctype. That is my personal test though. Investigating minification in site would be outside the scope of our support.

As I previously said, this varies depending on your server or WordPress setup. I also tried without HTML minification and used Google XML Sitemaps and I got no error. Please try deactivating Yoast SEO’s sitemap and try another solution.

Please try recreating your site in a development server and test other solutions. This is also a good opportunity to test if Pro is the root cause of the issue. You can do that by deactivating all third party plugins except your sitemap plugin and using the parent Pro theme and check if the issue persists.

Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.