Make WordPress Core

Opened 2 months ago

Last modified 5 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 (2)

#1 @Cybr
2 months ago

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

Last edited 2 months ago by Cybr (previous) (diff)

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


5 weeks 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

Note: See TracTickets for help on using tickets.