Incorrect language URL’s in XML-sitemap

#892187
  • Resolved G
    Rank Math free

    Hi,

    I have a question regarding the XML-sitemap of a client (https://groomzo.nl/faq-sitemap.xml). I see multiple language url’s in this specific XML-sitemap. However, the english url’s should not be in this XML-sitemap. How can I prevent them from appearing in this XML-sitemap? This also applies to the following XML-sitemap: https://groomzo.nl/faq-categorie-sitemap.xml. I see a mix between Dutch pages and English pages, however, only the dutch pages should be included.

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

    We apologize for the issue you are facing with the incorrect language URLs appearing in your XML sitemap. This can happen when using multilingual plugins like WPML, which may not correctly filter the URLs based on the language settings.

    To resolve this issue, you can add a specific piece of code to your theme’s rank-math.php file. This code will help ensure that only the correct language URLs are included in your sitemap. Here’s the code you can use:

    add_filter('rank_math/sitemap/entry', function ($url) {
        // Check if the URL is in the desired language
        if (strpos($url['loc'], '/en/') !== false) {
            return false; // Exclude English URLs
        }
        return $url;
    });

    This code checks if the URL contains /en/ and excludes it from the sitemap. You can adjust the condition based on your specific URL structure.

    If you continue to experience issues or need further assistance, please reply to this ticket, and a human agent from the Rank Math Support team will take over and provide more help.

    Thank you for raising this concern!

    Sources:
    Multilingual SEO with Rank Math SEO & WPML » Rank Math

    Hello,

    Thank you for contacting us. We apologize for any inconvenience this issue may have caused.

    We only include posts/pages/CPTs with self-referencing canonical URLs and with their meta robots set to index in the dynamically generated sitemap.

    If the page is not set to index or has a custom/different canonical URL it will be excluded from the sitemap.

    You can also use the Exclude Posts field in the Rank Math > Sitemap > General to prevent your desired pages from showing up in the sitemap.
    https://imgur.com/Xgd8wlO

    We checked the referenced sitemap and didn’t find any .com URL there.

    You can share a screenshot of where you see them using this tool: https://imgur.com/upload

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

    G
    Rank Math free

    Hi Ike,

    Thanks for your response. I’m familiar with the settings within the Rankmath plugin, however, I was looking (hoping) for an easier solution – if possible.

    The point is, the domain itself is presented in the Dutch language, hence the .nl-CCTLD. Though, if you explore the aforementioned XML-sitemap, you can see that there are several .com URL’s in the XML-sitemap for the .nl-domain (https://groomzo.nl/faq-categorie-sitemap.xml). Is there an easy way to exclude the .com pages from the .nl domain?

    Hello,

    Please update the filter to this so you can exclude .com URLs from the sitemap:

    add_filter('rank_math/sitemap/entry', function ($url) {
        // Check if the URL is in the desired language
        if (strpos($url['loc'], 'groomzo.com') !== false) {
            return false; // Exclude .com URLs from sitemap
        }
        return $url;
    });

    You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Once done, flush your sitemap cache by following the steps in this video:
    https://i.rankmath.com/pipRDp

    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.

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

The ticket ‘Incorrect language URL’s in XML-sitemap’ is closed to new replies.