Sitemap error: XML or text declaration not at start of entity
Are you seeing one of the following sitemap errors?
XML or text declaration not at start of entity
XML declaration allowed only at the start of the document
In this article we provide you with steps you can follow to solve this issue.
This issue typically happens when a plugin or theme function incorrectly adds empty whitespace at the beginning of the sitemap. Please view the source code of your sitemap following the steps here.
As much as we’d love to help, our plugin does not cause this issue. However, the cause most often is an empty line at the beginning (before the
<?php line) or end of the wp-config.php or functions.php file. If there is no empty line in these files, we highly recommend running a conflict check to identify what outputs the empty whitespace.
You may also need to clear your cache from your plugins/theme/CDN such as Cloudflare/server caching etc. If you are not sure how to clear cache, please speak with your developers or contact your host provider.
Once you have identified whether your theme or a plugin causes the issue, please contact the developers of the theme or plugin for assistance finding and removing the whitespace.
Sitemaps are great for helping crawlers find their way around your site. But, you know what is even better? An optimized site structure! Yoast SEO Premium makes it easy to improve and control the structure of your site. Among the many other benefits, it also comes with an internal linking feature and content filters. Their job is to make sure your audience and search engines find the posts and pages they need on your site.