Make WordPress Core

Opened 5 months ago

Last modified 3 weeks ago

#61293 new enhancement

Display an empty sitemap instead of 404

Reported by: cybr's profile Cybr Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Sitemaps Keywords: has-patch
Focuses: Cc:

Description

The sitemap can be empty when something filters its contents (I do that with The SEO Framework via indexability checks, such as "noindex").

When the sitemap is empty, WP_Sitemaps::render_sitemaps() currently bails to a 404.
I recommend sending an empty sitemap instead.

This change aligns with the user's expectations: They can actually see the sitemap and understand it is empty instead of "not working, eh, where do I start?".

Also, with the change, Google Search Console will say, "Sitemap can be read, but has errors" instead of "Sitemap could not be read". The former is a bit more descriptive of the situation.

Change History (3)

#1 @Cybr
5 months ago

The support topic that motivated me to create this ticket: https://wordpress.org/support/topic/sitemap-shows-nofollow-options/. We get one or two of these about every month.

Version 0, edited 5 months ago by Cybr (next)

This ticket was mentioned in PR #6903 on WordPress/wordpress-develop by @devansh2002.


4 months ago
#2

  • Keywords has-patch added

Removed the code block that forced a 404 response when the sitemap URL list was empty. This change allows empty sitemaps to return a valid XML structure instead of a 404 error, improving visibility for users and search engines.

This aligns with user expectations and provides clearer feedback in tools like Google Search Console.

Trac ticket: https://core.trac.wordpress.org/ticket/61293

#3 @Cybr
3 weeks ago

Another support topic about this confusing behavior: https://wordpress.org/support/topic/sitemap-404-error-15/.

Note: See TracTickets for help on using tickets.