Skip to content

Why Yoast SEO sometimes returns a blank XML sitemap

Yoast SEO sitemap URLs sometimes return a blank page or a white-screen fatal. Here is the real cause and the diagnostic path that does not involve toggling settings.

A request to /sitemap_index.xml or a sub-sitemap returns either an empty body, a blank white page, or a 500. Search Console flags coverage errors. Re-saving permalinks “fixes” it for a few hours, then it breaks again. Toggling Yoast SEO’s sitemap feature off and on resets it temporarily.

What’s actually happening

Yoast SEO generates sitemaps on demand and caches the output, but the rendering pass loads the full WordPress bootstrap, all active plugins, and every filter hooked to the_content or wp_head. A fatal error from any of them during sitemap generation produces an empty response — there is no XML declaration to emit because PHP died before the buffer flushed. The opcode cache then sometimes serves the broken state. Common triggers: a plugin that calls wp_get_current_user() during init without checking nonce context, a custom post type that registers with a broken filter callback, or memory exhaustion on a sitemap that has grown past the per-page limit.

How to verify

Hit the sitemap with curl, verbose, and check status plus body length:

curl -sI https://example.com/sitemap_index.xml
curl -s https://example.com/sitemap_index.xml | wc -c

A 200 with a body under 200 bytes is the empty-sitemap signature.

Now check what PHP logged at the exact request time. On a cPanel host:

tail -n 200 ~/logs/example.com.php.error.log | grep -E "Fatal|Allowed memory"

Or query the WP debug log if WP_DEBUG_LOG is on:

grep -i "sitemap\|Fatal" ~/public_html/wp-content/debug.log | tail -50

Memory exhaustion usually points at a sitemap shard with too many entries — Yoast SEO defaults to 1000 URLs per shard but custom types can blow past it.

The fix

  1. Resolve the underlying fatal first. Reproduce with WP_DEBUG and WP_DEBUG_DISPLAY off but WP_DEBUG_LOG on; identify the offending plugin from the stack trace.
  2. If memory is the trigger, raise the PHP CLI/FPM memory limit for the sitemap path specifically, or reduce the per-shard URL count by filtering wpseo_sitemap_entries_per_page.
  3. Flush the sitemap cache only after the underlying issue is fixed — otherwise it regenerates broken.
  4. Add a synthetic check on /sitemap_index.xml that validates body length and status. A blank sitemap is invisible until Search Console raises it days later.

For repeat offenders, sitemap regeneration belongs in CI, not in the request path.

Stack Harbor’s Deployment Management service pre-warms sitemap generation in staging so production never serves the broken state.