-
Hello,
I currently have the Weglot plugin with 8 languages installed.
http://www.mydomain.com/en/
http://www.mydomain.com/fr/
http://www.mydomain.com/de/
http://www.mydomain.com/it/
http://www.mydomain.com/no/
http://www.mydomain.com/pl/
http://www.mydomain.com/nl/Rank math only generates sitemaps in 1 language. I would like to know if there is a way to generate sitemaps for the rest of the languages.
Thanks in advance
Regards
-
Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.
Please note that Rank Math usually only handles adding the default language to your sitemap. Other languages are handled automatically by the translation plugin you use by adding a
hreflang
into each page automatically so that Google knows that it is a translated version of some other page.It is not a must that you have the translated pages in your sitemap. This is perfectly fine and as per guidelines set by Google:
https://developers.google.com/search/docs/advanced/crawling/localized-versionsHowever, if you still want, you can follow this guide to create a custom sitemap: https://rankmath.com/kb/custom-sitemaps/
Hope that helps.
Thank you.
Hello,
Thank you very much for your reply.
However it doesn’t work, is it my impression or is the code missing?
I have created a custom-sitemap.php file and added the following code:
\'\RankMathRouter::get_base_url( 'custom-sitemap.xml' ), 'lastmod' => '', ] ]; } public function get_sitemap_links( $type, $max_entries, $current_page ) { $links = [ [ 'loc' => 'http://www.mydomain.com/' ], [ 'loc' => 'http://www.mydomain.com/2',], ]; return $links; } }
Then I added the following code to the funtions.php
/*Mapa del sitio personalizado*/ include_once 'custom-sitemap.php'; add_filter('rank_math/sitemap/providers', function( $proveedores_externos ) { $external_providers['custom'] = new \RankMath\Sitemap\Providers\Custom(); return $proveedores_externos; });
But the website is giving an error and checking the server logs, it tells me the following:
AH01071: Got error ‘PHP message: PHP Parse error: syntax error, unexpected token “,” in /var/www/vhosts/mydomain.com/httpdocs/wp-content/themes/Impreza-child/custom-sitemap.php on line 4’, referer: https://mydomain.com/
Hello,
Could you please share the full code of your custom-sitemap.php file? You can paste it using this tool and share the generated link here.
Looking forward to helping you.
Thank you.
Hello,
The code you’re using for your custom sitemap is not correct. Please try to use the following code on your custom-sitemap.php:
<?php namespace RankMath\Sitemap\Providers; defined( 'ABSPATH' ) || exit; class Custom implements Provider { public function handles_type( $type ) { return 'custom' === $type; } public function get_index_links( $max_entries ) { return [ [ 'loc' => \RankMath\Sitemap\Router::get_base_url( 'custom-sitemap.xml' ), 'lastmod' => '', ] ]; } public function get_sitemap_links( $type, $max_entries, $current_page ) { $links = [ [ 'loc' => 'http://www.mydomain.com/fr/' ], //change URL here with the actual URL you want to include on your sitemap [ 'loc' => 'http://www.mydomain.com/de/',], ]; return $links; } }
After that please try to use the following code on your theme’s function.php:
include_once 'custom-sitemap.php'; add_filter('rank_math/sitemap/providers', function( $external_providers ) { $external_providers['custom'] = new \RankMath\Sitemap\Providers\Custom(); return $external_providers; });
Once done, please try to clear your sitemap cache by following the steps below:
1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp2. Exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
https://rankmath.com/kb/exclude-sitemaps-from-caching/You’ll be able to see your URLs on the
custom-sitemap.xml
like this one:If you still face any issues to include the custom sitemap then you can share your WordPress and FTP logins with us in the sensitive data section so that we can do this for you. Also, please share the URLs you want to include on your custom sitemap.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
Let us know how it goes. Looking forward to helping you.
Thank you.
Hello, Rakibuzzaman Siam
Thanks for your input. I will give it a try and get back to you shortly.
Best regards
Hello,
Sure! Let us know how it goes.
Meanwhile, please don’t hesitate to let us know if you have any other questions.
Looking forward to helping you.
Thank 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.
The ticket ‘Sitemaps for other languages Weglot’ is closed to new replies.