Hello,
Thank you for reaching out with your concerns regarding modifying sitemap issues in Rank Math. To address the specific issues you mentioned:
-
Removing 404 Error URLs from Sitemap:
- If you have URLs generating 404 errors in your sitemap, you can remove them by ensuring that those URLs are no longer linked on your website. Once the links are removed, Google will eventually drop them from its index.
-
Removing 301 Redirects from Sitemap:
- If you have URLs that are redirected using 301 redirects and you want to remove them from the sitemap, you should update the sitemap by replacing the redirected URLs with the final destination URLs. This can be done by editing the sitemap XML file directly or by using the Rank Math plugin to exclude specific URLs.
-
Removing Duplicate URLs from Sitemap:
- To remove duplicate URLs from the sitemap, you need to ensure that each URL in the sitemap is unique. If you have duplicate content on your website, you should address it by either setting canonical tags to point to the preferred version of the content or by removing the duplicate content altogether.
For manual modifications to your sitemap, you can follow these steps:
- Access your sitemap file directly through your website’s file manager or FTP.
- Locate the specific URLs you want to modify or remove.
- Edit the sitemap XML file accordingly by removing or updating the URLs as needed.
If you encounter any difficulties during this process or need further assistance, please feel free to reply to this ticket, and a human agent from the Rank Math Support team will assist you promptly.
Thank you for your understanding and patience.
Sources:
Rank Math Sitemap Issues and Their Fixes » Rank Math
Hello,
404 URLs should be automatically removed from the sitemap as well as duplicate ones.
If that’s not happening, please follow these steps to flush your sitemap cache:
1. Flush the Sitemap cache by following this video screencast:
https://i.rankmath.com/pipRDp
2. 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/
3. Disable the transient cache for the sitemap by applying this filter. This will make sure that your XML sitemap always reflects the latest changes on your site:
/**
* Filter if XML sitemap transient cache is enabled.
*
* @param boolean $unsigned Enable cache or not, defaults to true
*/
add_filter( 'rank_math/sitemap/enable_caching', '__return_false');
If you’re not sure how to add this code, you can follow this guide:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Regarding the redirects, please note that the sitemap will not remove redirected URLs that are still available in the WordPress backend.
You can either completely delete/unpublish those pages, or set them to noindex and they will be removed from the sitemap.
Looking forward to helping 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.