Background of the issue:
I am trying to use WPML and YoastSEO with the integration plugin (wp-seo-multilingual) to manage languages on my website. When I add a new language, all archives for this language are immediately added to the sitemap. I managed to remove the archives using some filters, but this should be fixed.
The issue seems to be coming from the file: 'wp-seo-multilingual/classes/class-wpml-wpseo-xml-sitemaps-filter.php'. To reproduce, simply add a new language to the website. Then, without translating any content, you will see the archives for all posts types in this language added to the sitemaps created by Yoast. Additionally, going to these archives will return a 200 (this is probably a different issue).
Symptoms:
When a new language is added, all archives for that language are added to the sitemap, even if there is no content. This includes the blog and all CPT's. Empty archives are indexed by Google without warning, which is not expected.
Questions:
Why are all archives added to the sitemap when a new language is added?
How can I prevent empty archives from being indexed by Google?
Languages: English (English )German (Deutsch )French (Français )
Timezone: Europe/Zagreb (GMT+02:00)
Can you tell me which filters have you tried? Something like this?
add_filter( 'wpseo_sitemap_entry', 'remove_empty_archives_from_sitemap', 10, 3 );
function remove_empty_archives_from_sitemap( $url, $type, $post ) {
if ( is_archive() && ! have_posts() ) {
return false; // Don't include this archive in the sitemap if there are no posts.
}
return $url;
}
Or this to exclude these from Google?
add_filter( 'wpseo_robots', 'noindex_empty_archives' );
function noindex_empty_archives( $robots ) {
if ( is_archive() && ! have_posts() ) {
return 'noindex,follow'; // Add noindex for archives with no posts.
}
return $robots;
}
The topic ‘[Closed] Adding a language to the website immediately adds all archives to the sitemap’ is closed to new replies.