Hello,
We apologize for the issue you are facing with the sitemap for your multi-language setup using Rank Math and the GTranslate plugin.
Rank Math automatically creates a sitemap for your posts and pages, but it may not generate separate sitemaps for each language in subdirectories by default. However, you can manage this by ensuring that your multilingual content is properly configured and that the sitemap settings are correctly set up.
Here are a few steps you can take to troubleshoot and potentially resolve this issue:
-
Check GTranslate Settings: Ensure that GTranslate is configured to create subdirectories for each language. This is crucial for Rank Math to recognize the different language versions.
-
Sitemap Index: Verify that your main sitemap index is accessible at `https://rankmath.com/kb/multiple-languages-seo-rankmath-translatepress/. This should include links to all your translated pages.
-
Manual Sitemap Creation: If Rank Math does not automatically create the sitemaps for subdirectories, you might need to manually create them or use a custom solution to ensure they are recognized by search engines.
-
Custom Code: If you are comfortable with coding, you can add custom code to your theme’s functions.php file to handle the generation of sitemaps for each language subdirectory. However, this requires some technical knowledge.
-
Contact Support: If the above steps do not resolve the issue, we recommend replying to this ticket, and a human agent from the Rank Math Support team will be able to assist you further.
Thank you for raising this concern, and we hope to help you get your multilingual sitemaps working as intended!
Thanks
I use GTranslate. You gave me documentation for another plugin.
I can mess with functions.php. Is there code ready for me to implement or should I look for it myself?
I tried this code but it did not work
`function custom_sitemap_languages() {
if ( class_exists( ‘RankMath\Sitemap\Router’ ) ) {
$languages = [‘en’, ‘es’, ‘fr’, ‘de’];
foreach ( $languages as $language ) {
add_filter( ‘rank_math/sitemap/enable_cpt_archive’, function( $enabled, $post_type ) use ( $language ) {
if ( is_sitemap_url() && strpos( $_SERVER[‘REQUEST_URI’], “/$language/” ) !== false ) {
return true;
}
return $enabled;
}, 10, 2 );
}
}
}
add_action( ‘init’, ‘custom_sitemap_languages’ );
Hello,
Thank you for contacting Rank Math support.
Rank Math does not generate sitemaps for the URLs that are translated by GTranslate. This is because GTranslate does not create actual pages for each language, but rather translates them on the fly when a visitor requests them.
But this does not really affect your SEO performance. Multilingual plugins add a special tag called hreflang to your pages, which tells Google and other search engines what language and region your page is targeting. This way, Google can find and index your translated URLs from the hreflang tag, and show them to the relevant users.
If you want to have more control over your multilingual sitemaps, you can also try WPML, TranslatePress, or Weglot as these plugins are fully compatible with Rank Math.
We hope this clarifies your question. Please let us know if you need any further assistance. We’re always here to help you.
Hello,
Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.
If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.
Thank you.