Is Your Sitemap Actually Working Properly?

An XML Sitemap with Image Tags — Why Replace WordPress’s Default Sitemap

So far, we’ve covered the index management group. Now we’re moving on to sitemaps.

We’ll start with the standard XML sitemap. WordPress already provides its own sitemap, wp-sitemap.xml, by default.

When I built SOHO SEO, however, I disabled it and created a completely new one. In this article, I’ll explain why I replaced something that was already there—and the problems I actually ran into along the way.

Where the Core Sitemap Falls Short

The biggest limitation of the WordPress core sitemap is that it doesn’t properly include image information.

The core sitemap essentially lists URLs and their last-modified dates. In the age of Discover, I don’t think that’s enough. As I’ve stressed throughout this series, Discover is an image-driven channel.

To help Google crawl and understand images properly, image information must be provided explicitly at the sitemap stage. That’s why I built a sitemap that includes the <image:image> tag.

By including the representative image URL in each post’s sitemap entry, Googlebot can discover the text and the image in a single crawl.

This is directly connected to the crawling-efficiency issues I discussed in earlier articles.

Crawl budget isn’t unlimited. Rather than making Googlebot take another route to discover images separately, it’s far more efficient to provide the text and image information together in a single sitemap.

A Fight for Control with Other Plugins

The moment you decide to build your own sitemap, a new set of problems appears.

WordPress sites typically have several plugins installed at the same time. Plugins such as Yoast, Rank Math, All in One SEO and SEOPress all generate their own sitemaps.

Most of them also try to register their sitemap at the same address: /sitemap_index.xml. That creates a fight over who gets control.

I ran into this problem in the real world. Someone reported that a new post wasn’t appearing in the sitemap. When I investigated, I found that SOHO SEO’s sitemap wasn’t failing to update at all. Instead, an old sitemap from another plugin—one I thought had been removed—was responding to the request.

That’s why SOHO SEO now explicitly calls the official “disable my sitemap” filters provided by Yoast, Rank Math, AIOSEO and SEOPress.

If one of those plugins isn’t installed, its filter is simply ignored without doing anything. This ensures that SOHO SEO’s sitemap is the only one responding on this site.

Taking Direct Responsibility for the Sitemap Line in robots.txt

By convention, robots.txt includes a line in the form “Sitemap: [URL]” to tell search engines where to find the sitemap.

But I’ve seen many sites where this line was left to chance—for example, a line added by Yoast years ago that simply remained in place.

So I made SOHO SEO manage this line directly, independently of whether any other plugin is present.

If the line is already there, it isn’t added again. If it’s missing, a new one is inserted.

The Incident Where a Sitemap Returned HTML Because of One Trailing Slash

I want to discuss one particularly troublesome bug I encountered while building this feature.

On a live site, requests to addresses such as /sitemap_index.xml and /sitemap-posts.xml were being given a trailing slash by WordPress’s canonical redirect feature, triggering a 301 redirect.

Normally, WordPress should recognize a dot in the requested path as indicating a file and skip this redirect. In the actual server environment, however, that wasn’t happening.

The request was therefore redirected to a URL with a trailing slash. Because that version didn’t match the sitemap plugin’s rewrite rules, WordPress treated it as the homepage.

The result? You could visit the sitemap URL and receive a 200 response with a Content-Type of text/html—but the actual content was the blog’s homepage.

The sitemap was returning homepage HTML instead of a sitemap.

Google Search Console flagged this with the error “Sitemap is HTML.” As I traced the issue, I couldn’t determine with complete certainty whether the exact cause was the hosting provider’s redirect rules or a change in WordPress core behavior.

Even though I couldn’t identify the cause with absolute certainty, I couldn’t simply leave the problem unresolved. So whenever a request with one of SOHO SEO’s sitemap-related query variables has already been recognized, I explicitly prevent the canonical redirect from running in the first place.

Whatever the underlying cause, this approach prevents the problem from recurring. I think bugs of this kind are among the most frightening aspects of developing an SEO plugin.

There was nothing wrong with the code itself; the unexpected result came from its interaction with other behavior in WordPress core.

The Problem of Caching Hiding New Posts

Another area that required careful attention was the interaction with caching.

The sitemap is generated anew on every request, but if a server or CDN cache such as LiteSpeed Cache has already stored a copy generated earlier, adding a no-cache header only takes effect from the next request onward.

It can’t delete an old copy that has already been stored. In fact, I encountered sites that had migrated from another SEO plugin to SOHO SEO where the old sitemap copy continued to be served unchanged, even as several new posts accumulated.

So whenever a post is published, updated or deleted, the relevant sitemap URLs are now actively purged from the cache immediately.

Because there’s no way to know in advance which caching plugin is installed, SOHO SEO does its best to call the URL-level cache-purge hooks provided by LiteSpeed Cache, W3 Total Cache and WP Rocket. If a given plugin isn’t installed, nothing happens, making this a safe approach.

This achieves the goal far more lightly than clearing the entire site cache. And once again, I confirmed on a live server that even this approach isn’t perfect.

URL-level purging works only when the caching plugin has stored that exact URL as the same string. In practice, differences in normalization or CDN layers sometimes meant the cached copy wasn’t actually removed. This is an issue I’m still monitoring.

Why Leave the On/Off Decision to the User?

Despite all these features, I left the sitemap on/off switch in the settings screen.

When it’s turned off, SOHO SEO does absolutely nothing related to sitemaps. It neither disables the WordPress core sitemap nor interferes with sitemaps generated by other SEO plugins.

This is the same approach used by Rank Math and Yoast. The reason is straightforward: there’s no point forcing SOHO SEO’s sitemap on users who are already happy with another sitemap solution.

This is a consequence of the code structure: the generator itself is called during WordPress’s init hook, so if rewrite rules are registered later here, they won’t run at all for that request.

So regardless of the setting, the rules are always registered synchronously and immediately. The setting determines only whether SOHO SEO actually responds to the request.

The Bottom Line on SOHO SEO’s Sitemap

An image-enabled sitemap may look like a simple feature on the surface. In practice, making it work reliably required attention to everything from conflicts with other plugins and unexpected redirects in WordPress core to clashes with multiple caching solutions.

I learned something during this process: there’s a significant difference between building a feature and making it work reliably in a live production environment. In reality, I spent far more time on the latter than on the former.

I’ve personally experienced sitemap errors while using a well-known plugin. I wouldn’t say that plugin was necessarily at fault, but building my own plugin taught me that ensuring system safety is neither easy nor impossibly difficult.

Choosing the system that works best for you based on experience can also be a form of wisdom.

In the next article, I’ll move on to Google News sitemaps. I’ll explain why the strict 48-hour rule exists and how it connects to freshness signals in Discover.