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, Yoast 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 and how to fix them.
Enabling XML Sitemap in Yoast SEO Plugin
After installing and activating the plugin, navigate to “SEO > General” menu. Go to “Features” tab to see the current status of the XML Sitemap. Ensure to turn on the button below “XML sitemaps” options so that the plugin will automatically generate a Sitemap Index for your site.
If you disable this option then Yoast SEO plugin will generate Sitemap and you can use the default WordPress Sitemap for your site.
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
- Sitemap not redirecting to sitemap_index.xml
- Custom posts / category Sitemaps not found
- Author / date archives redirecting to home page
- WordPress Sitemap not redirecting to Yoast Sitemap
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 [L]
RewriteRule ^locations.kml$ /index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /index.php?sitemap=geo [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 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 [L]
RewriteRule ^locations.kml$ /wordpress/index.php?sitemap=wpseo_local_kml [L]
RewriteRule ^geo_sitemap.xml$ /wordpress/index.php?sitemap=wpseo_local [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /wordpress/index.php?sitemap=$1&sitemap_n=$2 [L]
# 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 ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last;
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.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 SEO plugin. However, 1000 is also more to cause internal server error on most of the shared hosting environments like Bluehost.
Earlier, Yoast had an option for reducing the maximum number of entries per Sitemap. It was easy for users to change the limit to to 300 or 400 and check all the Sitemaps are accessible under Sitemap index. However, this option was removed later and there are no ways to restrict the URLs in each Sitemap.
The alternate option is to migrate to Rank Math plugin which allows you to generate Sitemaps with custom number of URLs as per your need. Other option is to disable XML Sitemap in Yoast and use the default WordPress Sitemap or use another plugin.
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 “https://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 “https://yoursite.com/sitemap_index.xml”. The Sitemap index file contains all individual Sitemaps as shown in the below 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
Yoast SEO plugin has a setup to enable or disable the corresponding Sitemaps for post types and taxonomies. Navigate to “SEO > Social Appearance” and check under the tabs “Content Types” and “Taxonomies” to enable or disable the required Sitemaps. For example, you can turn off “Show tags in search results” option to remove tags Sitemap from your XML Sitemap Index. In this case, you can find all the tag URLs as “Excluded” in your Google Search Console account’s “Coverage” section.
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 > Search Appearance > Archives” 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.
7. WordPress Default Sitemap Not Redirecting to Yoast Sitemap
As mentioned, WordPress by default will generate a XML Sitemap for your site without any plugin which will be in the below format:
https://your-site.com/wp-sitemap.xml
Yoast will automatically redirects WordPress Sitemap to Yoast Sitemap Index file. If this does not work, you will end up having two Sitemaps for your site. Make sure to test the redirection works fine, if not you may need to deactivate and reinstall Yoast SEO plugin to fix the issue.
Final Words
XML Sitemap is the key file for search engines to crawl and index your content. Though Yoast SEO is the popular plugin for WordPress, it does not cater all needs for having a customized XML Sitemap. If Yoast Sitemap does not work or you are not able to fix the issues, simply turn the option off and use default WordPress Sitemap or other plugin for this purpose.
3 Comments
Leave your reply.