Support » Plugin: Yoast SEO » Sitemap links do not have trailing /

  • Resolved SRD75


    Hi Folks, reports that there are 3XX redirects in the sitemap.

    In our linked sitemap, the post URLs do not have a trailing slash.

    Shouldn’t they?

    I’ve checked Settings > Permalinks, and it is set to “Post name” which contains a trailing slash.


Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter SRD75


    The links in the sitemap contain no trailing slash, which WordPress redirects to the URL with the trailing slash.

    Plugin Support Michael Tina


    Hi @srd75

    Yes, if you have included the trailing slash in your permalinks settings, it should reflect that way in the sitemap as well.

    Would it be possible for you to share your sitemap index URL here so we can try and take a look at this?

    Can you also try resetting our indexables in the database tables by following the steps below?
    1. Install & activate the Yoast Test Helper plugin
    2. Go to Tools > Yoast Test
    3. Locate the Yoast SEO section and click on the ‘Reset indexables tables & migrations’, ‘Reset Prominent words calculation’, and ‘Reset Internal link counter’ buttons. After each click, the page will reload to confirm that each reset was successful. Note: Resetting the optimization doesn’t undo any of the hard work you’ve put into the plugin as the SEO data is also stored in WordPress’ default tables. It’ll just reset the custom Yoast tables that contain the combined data pulled from those default tables.
    4. Go to SEO > Tools, and under SEO data, click the “Start SEO data optimization” button to allow Yoast to rescan your content.

    After completing the SEO data optimization process, could you then check if the trailing slash then appears for the URLs in the post sitemap?

    Thread Starter SRD75


    Hi Michael,

    I followed this procedure, but it didn’t work for:


    Thread Starter SRD75


    I cleared the Cloudflare cache for that URL but it didn’t resolve the issue.

    Plugin Support Jeroen Rotty



    Thank you for troubleshooting.

    Weird that this still happens while the posts themselves have the correct canonical (with trailing slash).

    I would ask you to do a conflict check to see if there is any plugin or theme conflicting and resulting in this behavior, as I can’t reproduce this.

    You can do this with the steps found here: Please check if the sitemaps shows when Yoast SEO is the only active plugin and while using a default theme such as Twenty Twenty (One).

    Thread Starter SRD75



    The Health Check plugin is installed.

    If I go to Tools > Site Health, I don’t see a ‘Troubleshooting’ tab.

    Plugin Support suascat_wp


    We expect the Troubleshooting tab to appear on the Heath Check page after Health Check plugin is activated.

    Could you please recheck?

    Alternatively, go to the Plugins list and there should appear a ‘Troubleshoot’ link on each plugin to manually activate and deactivate them to perform the conflict check.

    Thread Starter SRD75


    Thanks, I had WP Engine’s version of Health Check installed, which didn’t include the troubleshooting tools. Installing the standard version solved that problem.

    When only the default theme and Yoast SEO were activated, the posts had trailing slashes.

    When I activated a Code Snippets plugin, then the trailing slashes were removed.

    I see one of the snippets is:

    function mandoe_blog_rewrite_rules( $wp_rewrite ) {
      $new_rules = array(
        '(([^/]+/)*blog)/page/?([0-9]{1,})/?$' => 'index.php?pagename=$matches[1]&paged=$matches[3]',
        'blog/([^/]+)/?$' => 'index.php?post_type=post&name=$matches[1]',
        'blog/[^/]+/attachment/([^/]+)/?$' => 'index.php?post_type=post&attachment=$matches[1]',
        'blog/[^/]+/attachment/([^/]+)/trackback/?$' => 'index.php?post_type=post&attachment=$matches[1]&tb=1',
        'blog/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=post&attachment=$matches[1]&feed=$matches[2]',
        'blog/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=post&attachment=$matches[1]&feed=$matches[2]',
        'blog/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?post_type=post&attachment=$matches[1]&cpage=$matches[2]',		
        'blog/[^/]+/attachment/([^/]+)/embed/?$' => 'index.php?post_type=post&attachment=$matches[1]&embed=true',
        'blog/[^/]+/embed/([^/]+)/?$' => 'index.php?post_type=post&attachment=$matches[1]&embed=true',
        'blog/([^/]+)/embed/?$' => 'index.php?post_type=post&name=$matches[1]&embed=true',
        'blog/[^/]+/([^/]+)/embed/?$' => 'index.php?post_type=post&attachment=$matches[1]&embed=true',
        'blog/([^/]+)/trackback/?$' => 'index.php?post_type=post&name=$matches[1]&tb=1',
        'blog/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=post&name=$matches[1]&feed=$matches[2]',
        'blog/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=post&name=$matches[1]&feed=$matches[2]',
        'blog/page/([0-9]{1,})/?$' => 'index.php?post_type=post&paged=$matches[1]',
        'blog/[^/]+/page/?([0-9]{1,})/?$' => 'index.php?post_type=post&name=$matches[1]&paged=$matches[2]',
        'blog/([^/]+)/page/?([0-9]{1,})/?$' => 'index.php?post_type=post&name=$matches[1]&paged=$matches[2]',
        'blog/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?post_type=post&name=$matches[1]&cpage=$matches[2]',
        'blog/([^/]+)(/[0-9]+)?/?$' => 'index.php?post_type=post&name=$matches[1]&page=$matches[2]',
    //    'blog/[^/]+/([^/]+)/?$' => 'index.php?post_type=post&attachment=$matches[1]',
        'blog/[^/]+/([^/]+)/trackback/?$' => 'index.php?post_type=post&attachment=$matches[1]&tb=1',
        'blog/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=post&attachment=$matches[1]&feed=$matches[2]',
        'blog/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?post_type=post&attachment=$matches[1]&feed=$matches[2]',
        'blog/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$' => 'index.php?post_type=post&attachment=$matches[1]&cpage=$matches[2]',
      $wp_rewrite->rules = array_merge($new_rules, $wp_rewrite->rules);
    add_action( 'generate_rewrite_rules', 'mandoe_blog_rewrite_rules' );
    function mandoe_update_post_link( $post_link, $id = 0 ) {
      $post = get_post( $id );
      if( is_object( $post ) && $post->post_type == 'post' ) {
        return home_url( '/blog/' . $post->post_name );
      return $post_link;
    add_filter( 'post_link', 'mandoe_update_post_link', 1, 3 );

    The other snippets are not related to posts.


    Plugin Support suascat_wp



    Since you identified that this is related to another plugin, we recommend contacting Code Snippet plugin support or checking their documentation for more details about compatibility with Yoast SEO.

    We’re sorry that we could be of more help, but please, let us know if you have any other questions.

    Thread Starter SRD75


    I found the issue to be with the code:

    if( is_object( $post ) && $post->post_type == ‘post’ ) {
    return home_url( ‘/blog/’ . $post->post_name );

    Changing this to

    if( is_object( $post ) && $post->post_type == ‘post’ ) {
    return home_url( ‘/blog/’ . $post->post_name . ‘/’);

    Resolved the error.


Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.