An XML sitemap lists the URLs you want search engines to crawl, with last-modified dates. It helps them discover new and updated content faster, especially on larger sites, or sites with few external links. WordPress has a built-in sitemap since version 5.5, and SEO plugins replace it with more configurable versions.
Option 1: the built-in sitemap
Available at:
https://example.com/wp-sitemap.xml
It’s an index that links to sub-sitemaps for posts, pages, custom post types, categories, tags and author archives. It’s basic: no image entries, no lastmod for some types, and limited controls (you need code to exclude things).
Exclude a post type or taxonomy with a filter (in a small site plugin):
add_filter( 'wp_sitemaps_add_provider', function ( $provider, $name ) {
return $name === 'users' ? false : $provider; // drop author sitemaps
}, 10, 2 );
add_filter( 'wp_sitemaps_taxonomies', function ( $taxonomies ) {
unset( $taxonomies['post_tag'] ); // drop tag sitemaps
return $taxonomies;
} );
Option 2: SEO plugin sitemaps (most sites)
Yoast SEO, Rank Math, SEOPress and All in One SEO generate their own sitemap, and disable the core one automatically:
- Yoast:
/sitemap_index.xml - Rank Math:
/sitemap_index.xml - SEOPress:
/sitemaps.xml
Advantages: excludes noindex content automatically, includes images, accurate lastmod, per-post exclusion, and settings for post types and taxonomies.
Use only one sitemap source. If you run an SEO plugin, keep its sitemap and let it disable core’s.
What to include (and exclude)
Include: published posts, pages, products, and useful archives (main categories).
Exclude:
noindexpages (thank-you pages, cart, checkout, account, internal search);- thin archives (tags with one post, author archives on single-author blogs, date archives);
- attachment pages (Yoast and Rank Math redirect them to the file by default);
- staging and private content.
Sitemaps should only list canonical, indexable, 200-status URLs.
Submit it
- robots.txt: add the sitemap location:
Sitemap: https://example.com/sitemap_index.xml
- Google Search Console → Sitemaps → submit the URL. Check “Success” and the discovered URL count.
- Bing Webmaster Tools → Sitemaps (Bing can also import from Search Console).
Sitemap returns 404 on Nginx
Sitemaps are virtual URLs handled by WordPress. If you get a 404:
- Make sure your server block passes unknown URLs to WordPress:
location / {
try_files $uri $uri/ /index.php?$args;
}
- Some older guides add specific rewrites for Yoast sitemaps. With the
try_filesrule above, they’re usually unnecessary. - Flush permalinks:
wp rewrite flush. See WordPress permalinks 404. - A static file named
sitemap.xmlorsitemap_index.xmlleft in the web root overrides the dynamic one. Delete it.
Sitemap and caching
Page caching and CDNs can serve an outdated sitemap. Exclude *sitemap*.xml from the HTML cache, or make sure your cache purges it when content changes. See Nginx FastCGI cache.
Large sites
- Sitemaps are split into files of up to 50,000 URLs (plugins typically use 1,000–2,000 per file for performance).
- Generating huge sitemaps on every request is expensive. SEO plugins cache them. Check that the object cache is working. See Redis object cache.
Validate
curl -sI https://example.com/sitemap_index.xml | head -3 # 200, content-type xml
curl -s https://example.com/sitemap_index.xml | head -20
Check in Search Console for errors such as “Couldn’t fetch” or “Submitted URL marked noindex”.
Quick reference
| Source | URL |
|---|---|
| WordPress core | /wp-sitemap.xml |
| Yoast / Rank Math | /sitemap_index.xml |
| SEOPress | /sitemaps.xml |
| Announce | Sitemap: line in robots.txt + Search Console |
| 404 fix | try_files … /index.php?$args; + wp rewrite flush |
Related: WordPress schema markup and WordPress redirects.