Getting SEO by Yoast sitemap xml error in WordPress?
Are you getting an error when trying to open the SEO by Yoast XML sitemap? Something like “XML declaration allowed only at the start of the document”? Here is the solution.
How to fix Yoast sitemap xml error in WordPress
If you are using the SEO by Yoast WordPress plugin, this error “XML declaration allowed only at the start of the document“ is probably caused by some blank spaces before the opening <?xml tag. This has nothing to do with the SEO by Yoast plugin. Try one or more of the following solutions to fix the problem.
- On the XML sitemap error page, rightclick and “view source code”. Do you see a lot of blank space before the opening <?xml tag in the code? This is causing the sitemap error.
- Try to deactivate your other plugins one by one to see if this fixes the problem.
- If you are working with a child theme, check all your custom theme files. Is any file causing the blank space?
- Try to re-save all your custom theme fils to format “UTF-8 without BOM”. This is easily done in any text editor. Open the files and select encoding > convert to UTF-8 without BOM. Save and upload the files to your server, to see if this fixes the problem with the SEO by Yoast XML sitemap.