Automattic / Automattic/jetpack

Sitemaps: CPT sitemaps cause duplicate sitemap files

Open
#8,308 1 comment 0 reactions 0 assignees View on GitHub
[Feature] Sitemaps [Pri] Normal [Status] Stale Bug
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

### Steps to reproduce

1. Add a plugin that adds a CPT to your site.
2. Add many posts to that Post Type.
3. Whitelist that post type:
```php
/**
* Add Trakt events to sitemaps.
*/
function jeherve_add_trakt_sitemaps( $post_types ) {
$post_types[] = 'traktivity_event';
return $post_types;
}
add_filter( 'jetpack_sitemap_post_types', 'jeherve_add_trakt_sitemaps' );
```
4. Flush existing sitemaps and deactivate / reactivate the module to rebuild the sitemap.
5. When the sitemap gets rebuilt, you will see some of the sitemaps are duplicated. See some examples here:
https://jeremy.hu/sitemap-index-1.xml
https://jeremy.hu/image-sitemap-index-1.xml

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with a custom post type, many posts, and the jetpack_sitemap_post_types filter, then trace the sitemap rebuild path. Compare the generated sitemap index and image sitemap index URLs after flushing and rebuilding. Done means whitelisted custom post types no longer produce duplicate sitemap files.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, content
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.