Hello,
Thank you for contacting us and bringing your concern to our attention.
1. Unfortunately, there is no direct option to hide your sitemap for your visitors but you can use the following filter code on your website to change the sitemap slug so that your visitors can’t guess your sitemap URL:
/**
* Filter: 'rank_math/sitemap/index_slug' - Modify the sitemap index slug.
*
* @param string $slug Sitemap index slug.
*
* @return string
*/
add_filter( 'rank_math/sitemap/index/slug', function($slug) {
return $slug;
});
Here’s how you can add filter/hook to your WordPress site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
2. You can set the Links Per Sitemap in Rank Math > Sitemap Settings > General and Rank Math will automatically create another sub-sitemap for your posts/pages if the count exceeds the limit.
Hope that helps and please don’t hesitate to let us know if you have any other questions.
hi again thx for answer. if i use that code so no one cant find that, but google bots can find and crwal site map automaticly without any problem?
Hello,
1. If you use the filter code to modify the sitemap slug, it will obscure the sitemap URL from visitors, but Google bots and other search engines can still access and crawl the sitemap as long as it is submitted in Google Search Console or other webmaster tools. This approach ensures that your sitemap remains accessible to search engines while being hidden from visitors.
2. Regarding multiple sitemaps, Rank Math will automatically create sub-sitemaps if the number of links exceeds the limit set in Rank Math > Sitemap Settings > General. This is a standard practice for large websites and does not negatively impact SEO. It helps ensure that search engine bots can efficiently crawl all pages of your website.
We hope this helps. Please let us know if you have further questions or concerns.
Thank you.
thx. i made rank-math.php in my child theme and then add those code there
(
/**
* Filter: ‘rank_math/sitemap/index_slug’ – Modify the sitemap index slug.
*
* @param string $slug Sitemap index slug.
*
* @return string
*/
add_filter( ‘rank_math/sitemap/index/slug’, function($slug) {
return $slug;
});
)
now whene i use the link of sitemap it shows this:
This page contains the following errors:
error on line 1 at column 1: Start tag expected, ‘<‘ not found
Below is a rendering of the page up to the first error.
is it ok? am i done right all things?
and now i cant see sitemaps but google bot can? r u sure?
and last question: whene evere i will want to check site maps link i have to disable temporary this code from child theme?
another problem after add those filtes codes is on top of all pages i see the codes on explorer!!
as like image on this link:
https://s8.uupload.ir/files/sitemap_error_abqj.jpg
Hello,
This issue happens when the codes are applied incorrectly. Please ensure that you have added the opening PHP tag at the first line of the file
You can follow the steps in our guide on how to add a filter on your site:
https://rankmath.com/kb/filters-hooks-api-developer/
Looking forward to helping you.