Sitemap URLs Missing Trailing Slashes Despite Correct Permalink Settings

#1050465
  • Resolved Zeeshan Ex
    Rank Math free

    Hi Rank Math Team,

    I’m experiencing an issue where the URLs in my sitemap do not include trailing slashes, even though my WordPress permalink settings are correctly configured to use the “Post name” structure, which should end URLs with a slash (e.g., https://trendnama.com/sample-post/).

    Here’s the situation in detail:

    WordPress permalink is set to Post name, and I’ve saved the settings multiple times.

    The URLs on the front end redirect correctly to include the trailing slash (e.g., /my-post → /my-post/).

    However, in the Rank Math sitemap (/sitemap_index.xml), the post URLs do not end with a trailing slash (e.g., https://trendnama.com/my-post).

    This causes a 301 redirect on every sitemap URL, which might delay or negatively affect Google indexing.

    I’ve already:

    Flushed permalinks

    Disabled and re-enabled the Sitemap module in Rank Math

    Cleared all cache (WordPress, server, and Cloudflare)

    I’ve even verified that the canonical URLs and internal links are using the correct trailing slash format.

    Despite all of the above, the sitemap still outputs non-trailing slash versions of post URLs.

    Can you please advise on:

    1. Why the sitemap is ignoring the permalink structure?

    2. Whether this is a known issue?

    3. How to force the sitemap to always output URLs with a trailing slash?

    Thank you for your time and assistance.

    Best regards,
    https://trendnama.com
    My email is h*********@g********

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

    We apologize for the issue you are facing with the sitemap URLs not including trailing slashes. Thank you for providing detailed information about your situation.

    1. Why the sitemap is ignoring the permalink structure?
      The Rank Math sitemap should ideally respect the permalink settings. However, if it’s not reflecting the trailing slashes, it could be due to a conflict with another plugin or a specific setting within your theme or server configuration.

    2. Whether this is a known issue?
      While this is not a widely reported issue, it can occur in certain setups, especially if there are caching mechanisms or conflicting plugins involved. You’ve already taken steps to clear caches, which is great.

    3. How to force the sitemap to always output URLs with a trailing slash?
      Unfortunately, there isn’t a direct setting in Rank Math to enforce trailing slashes in the sitemap. However, you can try adding a filter in your theme’s functions.php file to ensure that URLs are generated with trailing slashes. Here’s a code snippet you can use:

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

      This will disable caching for the sitemap and may help in generating the correct URLs.

    If the problem persists after trying these suggestions, we recommend replying to this ticket so that a human agent from our support team can take a closer look at your specific setup and provide further assistance. Please include any additional details that might help us understand the issue better.

    Thank you for your patience, and we look forward to resolving this for you!

    Sources:
    Rank Math Sitemap Issues and Their Fixes » Rank Math

    Hello,

    Thank you for reaching out to Rank Math support.

    We checked your sitemap and can see the posts added to the sitemap all have a trailing slash:
    https://i.rankmath.com/i/U9WAEM

    If you are referring to something else, kindly share a screenshot with us. You can use the following tool to upload your screenshots and share the generated links here: https://imgur.com/upload

    We look forward to helping you.

    Thank you.

    Can you please share the Sitemap?? It’s not ending with the /

    Hello,

    We looked through the URLs on all the sub-sitemaps and did not find any post, page, or category URL without a trailing slash.

    Please note that the sitemaps, just like the robots.txt, usually do not have a trailing slash.

    Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    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.

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

The ticket ‘Sitemap URLs Missing Trailing Slashes Despite Correct Permalink Settings’ is closed to new replies.