Hello,
I’m sorry to hear that you are facing issues with your sitemap showing empty lines causing an XML declaration error. To resolve this problem, you can follow these steps:
-
Check for Plugin or Theme Issues: Empty lines in sitemaps can be caused by other plugins or themes. Ensure that there are no conflicts with other plugins or themes that might be adding these empty lines.
-
Exclude Sitemaps from Caching: If you are using caching plugins, make sure to exclude your sitemaps from being cached. Caching sitemaps can lead to them being displayed as empty or blank files.
-
Flush Permalinks: If you are using Rank Math and it doesn’t create a sitemap file or throws a 404 error, try flushing permalinks by going to Settings → Permalinks in your WordPress admin area and hitting the “Save Changes” button.
If you have already tried these steps and the issue persists, please let us know so we can assist you further. Thank you for reaching out!
Sources:
Remove Blank Lines From Sitemaps » Rank Math
Rank Math Sitemap Issues and Their Fixes » Rank Math
Plugins/ Themes that may create the issue:
– Rank Math
– WPML
– Divi
What I already tried (w/o success):
– Exclude Sitemaps from caching
– deleting all empty lines from divi child funktions.php
– installing Health Check Plugin and enabling troubleshooting Mode
– disabling all plugins except RM
– disabling the sitemap addon inside RM
Hello,
The issue you are seeing is caused by an XML declaration error on your sitemap. This means that there is some extra content or whitespace before the XML declaration in your sitemap file. This can make your sitemap invalid and unreadable by search engines.
The most common reason for this error is a whitespace in your theme code, such as a blank line or space in your wp-config.php file or your theme’s functions.php file. This can happen when you edit these files manually or use a plugin or theme that modifies them.
To fix this error, you need to find and remove the whitespace from your theme code. You can follow this guide to troubleshoot and resolve this issue: https://rankmath.com/kb/fix-sitemap-issues/#xml-text-declaration
If the issue persists, you can also use this script to automatically fix this error: https://wejn.org/stuff/wejnswpwhitespacefix.php.html
Looking forward to helping you
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.