Home » Technology » [Solved] WordPress Yoast SEO sitemap blank on Nginx

[Solved] WordPress Yoast SEO sitemap blank on Nginx

written by Anand July 25, 2014

After moving my WordPress blog to Nginx on Digital Ocean, I have had to work through a few issues, one of it being Yoast SEO sitemap blank problem. Likes most bloggers I use Yoast’s WordPress SEO plugin, which sort of eliminates the need for several other plugins for non-on-page SEO functions. One such function is XML sitemap generation. Yoast sitemap blank issue is different from the sitemap 404 error, which is more common. In my case the XML sitemap page was blank with nothing on it. If you came here trying to find answer to Yoast SEO sitemap blank problem then read on. [Read: 5 blogging mistakes I made when I started this blog]

Yoast SEO Sitemap Blank Problem

The pictures below describe the problem. As you can see the sitemap.xml file generated by Yoast’s WordPress SEO plugin is blank. If the sitemap is non-functional, it can cause issues with Google indexing your site properly or in a timely manner.

WordPress Yoast SEO Sitemap Blank

WordPress Yoast SEO Blank Sitemap

When I disabled W3 Total Cache, I could see the individual sitemap links but they were unformatted and were not linked. Visually this was a problem. [Read: Fix for WordPress blank page with the word "error”]

WordPress Yoast XML Sitemap Blank - No Style

WordPress Yoast XML Sitemap – No Style

When I viewed the sitemap’s HTML source code, it was wasn’t empty and it had what it is supposed to have. And when I check with sitemap with some of the sitemap validators I did not find any issues. So the problem was only visual.

Yoast XML Sitemap Source

Yoast XML Sitemap Source

But I wanted to fix this Yoast XML sitemap blank problem anyways. So here is what I did to make the WordPress SEO sitemaps work normally on Nginx webserver.

Recommended Guides:

Fix for Yoast XML Sitemap Blank Issue

The WordPress SEO plugin, upon activation, provides you the rewrite rules for Nginx web server. But additional rewrite rules are needed to make the XML sitemap generation part of the plugin work fully. The blank XML sitemap is due to the main-sitemap.xsl (XML stylesheet) being not redirected correctly. This is easily solved by adding the following rewrite rule to Nginx host file within the server blocks:

rewrite ^/([a-z[a-z]?sitemap\.xsl$ /index.php?xsl=$1 last;

If you are interested in seeing all the Nginx rewrite rules that I use to make the WordPress SEO plugin work correctly then take a look at the code block below:

# This rewrite redirects sitemap.xml to sitemap_index.xml, which is what Yoast's WordPress SEO plugin generates.
rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent;
# This rewrite ensures that the styles are available for styling the generated sitemap.
rewrite ^/([a-z[a-z]?sitemap\.xsl$ /index.php?xsl=$1 last;
# These rewrites rule are generated by Yoast's plugin for Nginx webserver.
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/][^/]sitemap([0-9[0-9].xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

I have uploaded this code to my Gist repository in case you would like to fork it or improve it. [Read: 6 FeedBurner tweaks to spruce up your WordPress feed delivery]

W3 Total Cache Settings to Prevent Yoast Sitemap Blank Problem

In addition to the Nginx rewrites to fix Yoast SEO sitemap blank bug, you also need to configure your W3 Total Cache correctly and apply necessary exclusions to avoid caching or minifying your sitemap and related files. Add the following code to Page Cache (Never cache the following items), Minify (Never minify the following items), Browser Cache (404 Error Exception List), and CDN (Rejected Files) sections of W3 Total Cache.


The above code is also available on my Gist repository for rework. Here is a screenshot of where the above line of code needs to go in W3 Total Cache settings.

W3 Total Cache Settings for Yoast XML Sitemap on Nginx

W3 Total Cache Settings for Yoast XML Sitemap on Nginx

Once you entered your rewrite rules and added necessary settings to your W3 Total Cache configuration go ahead and restart your Nginx webserver and clear any caches. This should have solved your Yoast SEO sitemap blank problem.

IPVanish VPN Exclusive 20% Off - only $5.19/month:
VPN Guides
Windows, Android, Ubuntu
Kodi OpenVPN
♦ Hide your browsing (no logs), Anonymize Streaming and Downloads
♦ Circumvent Geo/Country Restrictions and access worldwide content
♦ Works on Windows, Mac, Linux, Android, iOS, Router, and more
♦ Money back guarantee - Sign Up Now

Super Hot deal for National Cybersecurity Awareness Month. 2-years premium VPN from IPVanish for $99 (only $4.12 per month)

Related Articles


farzaneh mrz September 8, 2014 - 11:50 am

thank you so much.

you solve my problem.

Anand September 8, 2014 - 12:06 pm

You are welcome!

SSL part October 30, 2014 - 7:43 am

Great article it really worked, this should be pointed out to both the W3Total Cache and SEO by Yoast.

Abhisheek November 6, 2014 - 6:19 am

I’ve purchased Yoast News SEO plugin extension but it shows 404 error page while viewing News Sitemap here: http://tvchaska.net/news-sitemap.xml

I’m using NGinx server

Rafa Labrador January 9, 2015 - 7:24 am

Thanks a lot! The W3 Total cache configuration you explained worked for me. Now sitemaps is always show with style.

Nikos Meramveliotakis October 20, 2015 - 3:44 am

Hello Anand

Thank you very much for your post. It solved my problem!
I had a sitemap without any style and a 404 error at my search console.
I use Nginx but i didn’t use the rewrite rules you mention, only the Cache Settings below.
Everything is fine now with both style and 404 error.
Thank you very much.


Leave a Comment