Do not cache your XML sitemaps
If you can’t see your XML sitemap or you get this error from Google Search Console “Your file appears to be an HTML page“:
- exclude XML and XSL files from your caching plugins
- exclude XML and XSL files from Weglot plugin
- exclude XML and XSL files from your CDN (Content Delivery Network)
- update Really Simple SSL plugin to the latest release
My XML sitemap returns a 404 error
Flush your permalinks from Settings, Permalinks each time you include or exclude a new post type or taxonomy to your sitemap.
You must add several rewrite rules to your NGINX configuration file. Contact your webhost to take of this.
Google Search Console returns errors
Generating an XML sitemap for your images is a daunting task, especially if you are using shortcodes to display your images.
- The first thing to try is to disable the execution of shortcodes in XML sitemaps of images with a hook (paste it to your functions.php file of your child theme / theme)
- Disable Image sitemap from SEO, XML – HTML sitemap settings page, General tab
My XML sitemap is blank
There may be a problem with the stylesheet associated with the XML sitemap. It may not be loading or has been altered via your theme or a third-party plugin.
Generally, by looking at the source code of the stylesheet, we can quickly find the culprit.
URL of the stylesheet: https://example.com/sitemaps_xsl.xsl
Or, if your index sitemap and / or sub-sitemaps are blank, including your source code, you have to enable the WP Debug feature to get the error. Once the debug is enabled, load again your XML sitemap. The error will appear in your debug.log file.
A URL is missing in my sitemap
Make sure you don’t have set your URL as noindex.
If you have set a custom canonical tag different from your permalink, it will be automatically excluded from the sitemap too to follow Google guidelines.
The source code of my sitemaps shows “extra code”
If you see some PHP or JS scripts related to a third party plugin, you can try to disable shortcode execution by adding this snippet to your functions.php file of your child theme (you can also use a must use plugin if you prefer or if you don’t have this file available, eg Oxygen builder):
My sitemap is too slow
Try to disable Image sitemaps option from the General settings.