404 pages in the sitemap

#841450
  • Resolved Sonia
    Rank Math free

    Hello,

    I’m using Rankmath to create my sitemap but I am constantly facing issues. I am not using any cache plugin and my settings are fine, however RankMath has been including pages that don’t exist in my sitemap…

    Could you please help? Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    I’m sorry to hear that you are facing issues with your Rank Math sitemap showing 404 pages. One common reason for this issue is that the pages might be excluded from the sitemap settings in Rank Math.

    To resolve this, please check the Sitemap Settings in Rank Math and ensure that the pages you want to include are not excluded under Exclude Posts or Exclude Terms. Additionally, make sure that any empty archive pages are included by enabling the Include Empty Terms option in the category/tag/custom taxonomy archive settings.

    If the issue persists after checking these settings, you can also add a filter to disable sitemap caching in your theme’s rank-math.php file by using the following code:

    add_filter( 'rank_math/sitemap/enable_caching', '__return_false');

    After adding this filter, recheck your sitemap to see if the problem is resolved. If you continue to face difficulties, please feel free to reach out to our dedicated support team for further assistance. They are available 24/7 and will be happy to help you with any sitemap issues you might encounter.

    Thank you for reaching out!

    Sources:
    Rank Math Sitemap Issues and Their Fixes » Rank Math
    Why Isn’t My URL Included in the Sitemap? » Rank Math
    Why the Sitemap_Index.xml is Throwing a 404 Error » Rank Math

    Sonia
    Rank Math free

    Thank you, but the issue is that pages that don’t exist are included in the sitemap when they shouldn’t be (not that pages that I’d like to have in the sitemap are not included).

    Hello,

    Rank Math generates the sitemap for your site dynamically and by default only includes existing posts/pages/CPTs whose meta robots are set to index and have self-referencing canonical URLs.

    You can also try disabling the transient cache for the sitemap. This will make sure that your XML sitemap always reflects the latest changes on your site. To do this, you need to add a small piece of code to 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/.

    If this doesn’t help then we might need to take a closer look at your settings.

    Please edit the first post on this ticket and include your WordPress logins in the designated Sensitive Data section.

    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/

    We really look forward to helping you.

    Sonia
    Rank Math free

    Hello Ike,

    Thank you for your help! The cache was not the issue, but in the end I was still able to solve it.
    WPML had automatically created some empty pages for translations and these pages were not visible in the WP back-end, so I couldn’t see or delete them. I had to go in the database to delete them, and then RankMath updated the sitemap instantly. SO in the end it was a WPML & database issue, not a RankMath issue. Thanks for the code though! I added to my rank-math.php file, just in case it can prevent future issues.

    Have a great day!

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘404 pages in the sitemap’ is closed to new replies.