1. Home
  2. Knowledge Base
  3. SEO Suite
  4. Rank Math Sitemap Issues and Their Fixes

Rank Math Sitemap Issues and Their Fixes

Not able to use the Sitemap functionality of Rank Math? Is it throwing errors at you? Don’t worry, the issue is simpler than you think and the solution is even simpler.

How to Fix Sitemap Issues in Rank Math?

1 The Sitemap is showing a blank or white page.

The first thing you need to do is determine whether you have a blank page or a white page. It sounds all the same but there is a difference. Check the source code of the blank/white page.

Let’s take the example of a website- https://rankmath.com/. If the sitemap shows a white page with no data on the front end, but, there are data in the source code, accessing the sitemap via this URL https://rankmath.com/?sitemap=1, in most cases, would show all the data on the frontend.

But in the URL- https://rankmath.com/?sitemap=1, where the sitemap still does not load, then, in that case, the source code is also blank.

Blank Sitemap

If the source code of the sitemap page is empty, there must be a conflict with another plugin or the theme. You can use the Health Check plugin to determine which plugin or theme is causing this.

But, if there is data in the source code, flushing the sitemaps cache and excluding it from the caching plugin fixes the issue.

Changing the sitemap settings from Rank Math and permalinks.

Another scenario is that you have a static file with the same name as your sitemap file (sitemap_index.xml). You should FTP into your server and remove the file.

If that does not solve, you might need to add a custom code to your functions.php or rank-math.php file from the theme files. In order to add custom code, we have a dedicated knowledgebase article on how to add a filter/ hook to your site.

add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

Note: Rank Math generates sitemaps on runtime. If there is any physical sitemap file present on the website, you can see unexpected behaviors that include either one or both of the above issues.

2 Rank Math Does Not Create a Sitemap & Throws a 404 Error

If Rank Math doesn’t create a sitemap file or if you are getting a 404 error while trying to access your sitemap index, you may have to flush permalinks. Don’t be scared, it is fairly easy to do.

Simply head over to your WordPress admin area and go to Settings > Permalinks and hit the “Save Changes” button once even if you didn’t make any changes on the page.

Flush permalink settings

This should fix the issue.

3 Why is there an ‘XML or text declaration not at the start of entity’ error inside Google Webmaster Tools?

There must be some white-spaces before the XML Sitemap’s source code.

blank-space-sitemap

This might be added by a blank line/space in your wp-config.php file or your theme’s functions.php file. If there is no such blank space in your wp-config.php or functions.php file, check for a plugin conflict using the Health Check plugin.

Also, make sure your cache is disabled as it is highly likely that the cache is interfering with the working of Sitemap functionality of Rank Math.

4 I am getting a `Missing XML tag` error

This is most likely because:

  1. You have no content on your website
  2. You have blocked all post/pages from appearing in your sitemap

First, one can be fixed by adding some content to your website.

The second one can be fixed by making sure you don’t block useful posts/pages/taxonomies from being included in your sitemap. You can do so by going to Rank Math > Sitemap Settings and checking the option for each type of post/taxonomy.

5 My Sitemap is not working on my Apache Web-Server.

Rank Math creates a virtual Sitemap dynamically when you enable that module. We rely on redirects enabled by your server software to accomplish that. If the Sitemap doesn’t work, you may have to add some rewrite rules manually.

To ensure you need to add these rewrite rules, go to domain.com?sitemap=1. If it loads your sitemap, that means you need to add the rewrite rules.

Check your .htaccess and add the following code:

# START of Rank Math Sitemap Rewrite Rules
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
RewriteRule ^([a-z]+)?-?sitemap.xsl$ /index.php?xsl=$1 [L]
# END of Rank Math Sitemap Rewrite Rules

6 My Sitemap is not working on my Nginx Web-Server.

Rank Math creates a virtual Sitemap dynamically when you enable that module. We rely on redirects enabled by your server software to accomplish that. If the Sitemap doesn’t work, you may have to add some rewrite rules manually.

To ensure you need to add these rewrite rules, go to domain.com?sitemap=1. If it loads your sitemap, that means you need to add the rewrite rules.

Check your Nginx config file and add the following code:

# START Nginx Rewrites for Rank Math Sitemaps
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
# END Nginx Rewrites for Rank Math Sitemaps

7 Why am I getting “Your file appears to be an HTML page” error in Google Webmaster Tools?

Make sure that you submitted the correct XML sitemap to Google. You should submit the sitemap available on your website at https://domain.com/sitemap_index.xml

If you are sure you submitted the correct URL but you are still facing this error, check for a plugin conflict using the Health Check plugin.

If you are running W3 Total Cache along with Rank Math on your website, make sure you create another user agent group and add the ‘googlebot’ user agent to it.

When the above solutions don’t help in resolving the issue, include the following filter to your theme’s functions.php or rank-math.php file.

add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

8 My Sitemap URL is blocked by robots.txt

This usually happens because of unintended rules in the robots.txt file or because of some weird plugin conflict. Make sure you don’t have any rules in your actual robots.txt file or the virtual robots.txt file added by Rank Math by going to Rank Math > General Settings > robots.txt

9 Due to Custom Canonicals in Sitemap

Rank Math by default includes a self-referencing canonical for all posts that are set to Index. If you’re adding a custom canonical to a post, then it wouldn’t appear in the sitemap.

Because, the actual post sitemap parser extracts the URLs allocated to the post sitemap XML and removes the ones with the different canonical, resulting in a lower number than the URLs initially loaded by the main parser.

Hence, the number of URLs on your site would not match the number in the sitemap.

So if you want all your posts to be shown in the sitemap, then you should remove the custom canonical from all your posts, and then allow Rank Math to generate the canonical.

10 Google Can’t Find my Sitemap.

If you are getting a 404 error and Google can’t access your sitemap index, you may have to flush permalinks. Don’t be scared, it is fairly easy to do.

Simply head over to your WordPress admin area and go to Settings > Permalinks and hit the “Save Changes” button once even if you didn’t make any changes on the page.

This should fix the issue.

If you are still facing any sort of issue with the Sitemaps, open a new ticket here so that our staff can help.

Was this article helpful?

Still not using Rank Math?

Setup takes less than 5 minutes including the import from your old SEO Plugin!

Learn more about the PRO Version

Still need help?

?

Submit Your Question

Please give us the details, our support team will get back to you.

Open Ticket

Related Articles