If you’ve landed at this article, I’m assuming you already have some familiarity with Yoast and its purpose for existing. If you’re not in that bucket of folks, Yoast is a search engine optimization (SEO) tool for WordPress which… optimizes your content for search engines! This lets machines comprehend what material to surface when someone executes a search.
Sitemaps are the first link in that process chain. They instruct the machines on where to find your content by specifying the URLs where they’re located. So, when a sitemap isn’t generating it could mean missed site visits and potential revenue. So I’d like to share with you a few debugging tips I’ve used to get it working again!
With the Yoast plugin enabled, going to {your.website.here}/sitemap.xml should redirect you to {your.website.here}/sitemap_index.xml. If that’s not happening, you should check the following:
1. Is your data optimized for SEO?
From your site’s admin panel, go to Yoast SEO -> General. If you see a notification like the one below, showing a button to “Start SEO data optimization”, it means your data is not in an optimized state. This causes issues for the Yoast plugin when it’s trying to generate the sitemap.

While you can simply click that button the red arrow is pointing at to fix this, I highly recommend you use the command line (if available). This process is prone to timeouts for very big data sets. Performing this operation via the command line is much safer and guarantees it won’t fail partway. In order to do it via the command line you just have to issue the following command:
wp yoast index
If this doesn’t fix your issue, you might have to start with a clean slate. In which case you should use the optional —-reindex flag like so:
wp yoast index --reindex
This flag will drop your existing Yoast index tables and recreate them from scratch.
2. Try “power cycling” the sitemap feature.
If your data has already been optimized, then you should attempt to “power cycle” Yoast’s sitemap feature. Believe it or not, this is actually Yoast’s recommendation. From the admin panel, go to Yoast SEO -> General -> Features -> XML Sitemaps and flip the switch from On -> Off. Finally, click on save.

If you see a 404 (page not found) when you go to {your.website.here}/sitemap_index.xml, you performed this step correctly. Now go back to the same setting and turn it back on. If you’re lucky, you’ll see your sitemap loading again! If you’re not, keep reading.
3. Do you have too many Tags? Categories?
Yoast’s plugin provides the capability to limit the type of content that is presented in the sitemap. You can turn off/on various content such as Posts, Pages, Taxonomies (Tags/Categories), Archives, etc. Try turning these off/on, one-by-one, reloading the sitemap after each time, to see if you’re able to narrow down which type of data is causing this issue.
I suggest starting with Tags, as those tend to get out of hand if not properly maintained. From the admin panel, go to Yoast SEO -> Search Appearance -> Taxonomies -> (scroll down to) Tags.

If your sitemap manages to load after this, congratulations! You now have a Tag clean-up job on your hands! If not, you’ll need to get your hands dirtier to fix this.
4. Yoast Test Helper Plugin.
Installing Yoast Test Helper will give you some additional controls over how the sitemap is generated. One extremely helpful feature is the ability to limit the number of links per content-type per sitemap. After installing this plugin from the admin panel, go to Tools -> Yoast Test -> XML Sitemaps.

Try setting the maximum entries per sitemap to a low number, to see if that allows the sitemap to be generated.
Another useful feature this tool provides is the ability to completely reset all the database tables Yoast relies on. This will give you the cleanest slate possible to start from.

5. Yoast Custom Filters.
You can use custom Yoast filters to further fine tune the type of content that is included in the sitemap. In order to use these filters, you’ll have to create a custom plugin, and register these filters on plugin activation.
6. WP Shell!
By now you’ve followed the previous steps and still haven’t been able to generate your sitemap. There’s one last hope for you, if you have command line access. You could get a sitemap to generate by executing the following commands:
wp shell
> $sitemap = new WPSEO_Sitemaps();
> $sitemap->init_sitemaps_providers();
> $sitemap->build_root_map();
> $sitemap->output();
The sitemap will be output onto the terminal. In an emergency, you could use that output to manually create a sitemap on the site. This is not a permanent solution however, as this sitemap will not be updated as new content is created on the site unless it is manually recreated. Read this article here, which initially gave me the idea about using this method to generate the sitemap. It even explains how to set up a cron job to force the sitemap to stay updated and always generate.
Thank you for stopping by! I hope you found this information helpful. Please give me a follow on Twitter. Cheers!


Leave a Reply