Fix Sitemap Issues with Yoast WordPress SEO Plugin

Yoast WordPress SEO plugin is among one of the highly rated and most used SEO plugins for WordPress. Besides allowing to add custom meta description, title and other on-page optimizations it also offers many other additional features. Some of the additional functionalities like adding breadcrumbs, redirecting attachment images to post, XML Sitemap, webmaster tools verification, etc. help the users to use a single plugin for all SEO purposes. Unfortunately the XML Sitemap feature can create some problems for your WordPress site. In this article let us explore the possible XML Sitemap issues with Yoast WordPress SEO plugin.

Enabling XML Sitemap in Yoast SEO Plugin

Once installed and activated the plugin, navigate to “SEO > XML Sitemaps” menu to see the current status of the Sitemap. Ensure the status is “Enabled” and there is a “XML Sitemap” button with the text before reading “You can find your XML Sitemap here:”

Enable XML Sitemap in Yoast WordPress SEO Plugin
Enable XML Sitemap in Yoast WordPress SEO Plugin

If the Sitemap is disabled then the “XML Sitemap” button will disappear automatically.

Possible Sitemap Errors with Yoast WordPress SEO Plugin

Below are the possible errors related to XML Sitemap based on our experience:

  • Sitemap Not Working at all
  • 404 Page Not Found error
  • 500 Internal Server Error
  • xml not redirecting to sitemap_index.xml
  • Custom posts / category Sitemaps not found
  • Author / date archives redirecting to home page
Related:  Top 6 Free Gallery Plugins for WordPress

The possible fixes are explained in the following sections.

1. Sitemap Not Working At All

If you see the Sitemap is not opening or showing white page then try out the followings:

  • Disable XML Sitemap in Yoast plugin.
  • Navigate to “Settings > Permalinks” and save your changes.
  • Enable XML Sitemap in Yoast plugin again.

Sometimes changing the permalinks structure and reset it back may also help.

2. 404 Page Not Found Error

If the XML Sitemap is pointing to 404 Page Not Found error then Yoast recommends to add the piece of code to fix the problem. Yoast SEO plugin itself have an option to modify the .htaccess file under “SEO > Tools > File Editor”.

For Apache Servers with WordPress installed on “/public_html” add the below code before the WordPress permalinks rewrite starts.

# Start Yoast SEO - Sitemap Fix for Normal WordPress Install
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 
RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml 
RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo 
RewriteRule ^(+?)-sitemap(+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 
RewriteRule ^(+)?-?sitemap.xsl$ /index.php?xsl=$1 
# END Yoast SEO - Sitemap Fix for Normal WordPress Install

In case if you have WordPress installation on sub-folder then add the below code in .htaccess file. The subdirectory in this example is “wordpress” which you can change with your own subdirectory name.

# Start Yoast SEO - Sitemap Fix for Subdirectory WordPress Install
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^sitemap_index.xml$ /wordpress/index.php?sitemap=1 
RewriteRule ^locations.kml$ /wordpress/index.php?sitemap=wpseo_local_kml 
RewriteRule ^geo_sitemap.xml$ /wordpress/index.php?sitemap=wpseo_local 
RewriteRule ^(+?)-sitemap(+)?.xml$ /wordpress/index.php?sitemap=$1&sitemap_n=$2 
# END Yoast SEO - Sitemap Fix for Subdirectory WordPress Install

If you use Nginx server then add the below code in Nginx server config file:

# Yoast Sitemap Fix
location ~ (*)sitemap(.*)\.x(m|s)l$ {
## this redirects sitemap.xml to /sitemap_index.xml
rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
## this makes the XML sitemaps work
rewrite ^/(+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/(+?)-sitemap(+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
## The following lines are optional for the premium extensions
## News SEO
rewrite ^/news-sitemap\.xml$ /index.php?sitemap=wpseo_news last;
## Local SEO
rewrite ^/locations\.kml$ /index.php?sitemap=wpseo_local_kml last;
rewrite ^/geo-sitemap\.xml$ /index.php?sitemap=wpseo_local last;
## Video SEO
rewrite ^/video-sitemap\.xsl$ /index.php?xsl=video last;
}

3. 500 Internal Server Error

The 500 internal server error can happen either when you click on your “sitemap_index.xml” file or when you click on the individual Sitemaps part of the index file like “post-sitemap.xml”. In most of the scenarios it is due to the PHP script run time restriction on the host level. In order to reduce the run time you can reduce the number of entries in each Sitemap. By default the number of entries in each Sitemap is restricted to 1000 in Yoast WordPress SEO plugin. But 1000 is also more to cause internal server error on most of the shared hosting environments like Bluehost.

Related:  Change DNS Server in iOS for iPhone and iPad
Reduce Number of Entries in Sitemap Files
Reduce Number of Entries in Sitemap Files

So reduce the max. entries per Sitemap to 300 or 400 and check all the Sitemaps are accessible under Sitemap index. When you change the number of entries, all individual Sitemaps like posts, tags, and categories will be restructured accordingly. Hence, it is highly recommended to resubmit your Sitemap to Google and other search engines after finalizing the number of entries.

4. Sitemap.xml Not Redirecting to Sitemap_index.xml

The default Sitemap of a WordPress site can be accessed with the URL “http://yoursite.com/sitemap.xml”. But Yoast plugin does not create “sitemap.xml” file instead it dynamically creates Sitemap index file. The index file can be accessed with the URL “http://yoursite.com/sitemap_index.xml”. The Sitemap index file contains all individual Sitemaps as shown in the below example:

Yoast XML Sitemap Index File Example
Yoast XML Sitemap Index File Example

Generally “sitemap.xml” will automatically redirect to “sitemap_index.xml”. But in some cases, the Sitemap will not redirect and you need to add manual redirection for this purpose. Add the below code under .htaccess file.

Redirect 301 /sitemap.xml /sitemap_index.xml

You can also add redirection using plugins like redirection directly from WordPress admin dashboard or through your hosting account. If you are using Nginx server then refer the above section 2 for correcting 404 page not found error, which also has a redirection from “sitemap.xml” to “sitemap_index.xml” file.

5. Custom Posts or Categories Sitemaps Not Found

When you use custom posts / categories / tags, Yoast SEO plugin has a setup to enable or disable the corresponding Sitemaps. Navigate to “SEO > XML Sitemaps” and check under the tabs “Post Types” and “Taxonomies” to enable or disable the required Sitemaps. For example, we have a custom taxonomy named “FAQ Categories” and disabling this will remove the corresponding Sitemap from the index file.

Related:  5 Free Mockup Generator Tools to Create Device Mockups
Enable or Disable Custom Sitemaps
Enable or Disable Custom Sitemaps

6. Author or Date Archives Redirecting to Home Page

When single author handles the whole blog there will be no need of separate author archive Sitemap. This is to avoid duplicate content under two different URLs of the author archive page as well on the blog index page. Similarly for a single author blog all date archive, author archive and blog index page will have the same content.

When you disabled author archives and date-based archives under “SEO > Title & Metas” section then those archive pages will be redirecting to your home page. Check the settings and enable or disable the archives as per your need.

Redirect Author and Date Archives to Home Page
Redirect Author and Date Archives to Home Page

Recommended Articles:

3 thoughts on “Fix Sitemap Issues with Yoast WordPress SEO Plugin”

Leave a Comment