Problem with sitemap

#949106
  • Resolved Sergio Labayen
    Rank Math free

    Good afternoon. I have a problem with my sitemap, generated by rank math. The url of my site in Spanish is https://elenoalkain.eus/es/, but in the sitemap it appears like this: https://elenoalkain.eus/es/home-i/ And I can’t change it in any way. I have checked all the settings in WordPress and Rank Math and everything is OK. In WPML everything is apparently fine too, but my suspicion is that the problem comes from there. Could you help me? Thank you very much.

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

    We apologize for the issue you are facing with your sitemap. It seems that the incorrect entry for your Spanish homepage in the sitemap is a common issue when using WPML with Rank Math.

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

    1. Access your theme files via FTP or your hosting file manager.

    2. Locate the rank-math.php file in your theme’s directory.

    3. Add the following code snippet to that file:

      // Custom code to fix incorrect entries for translated homepages
      add_filter( 'rank_math/sitemap/entry', function( $entry, $post ) {
         if ( $post->post_type === 'page' && $post->post_name === 'home-i' ) {
             $entry['loc'] = home_url( '/es/' ); // Change this to your correct homepage URL
         }
         return $entry;
      }, 10, 2 );
    4. Save the changes and check your sitemap again.

    If you continue to experience issues, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further. Thank you for raising this concern!

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

    Sergio Labayen
    Rank Math free

    I have placed the code in rank-math.php file, but the problem persists. I have tried different ways, and nothing works.

    Hello,

    We’ve checked your sitemap, and the correct homepage URL is already shown

    wpml

    If you’re still seeing the incorrect URL, please clear your website’s cache or check using a different browser.

    Looking forward to helping you.

    Hello,

    Although Rank Math only generates the primary language of the site for the sitemap, yes, this setup is also fine. This helps search engines index the content for each language correctly.

    Don’t hesitate to get in touch with us if you have any other questions.

    Sergio Labayen
    Rank Math free

    Thank you very much

    Hello,

    We’re delighted to hear that this issue has been resolved. We appreciate your feedback.

    This ticket will be closed now, but if you ever have another question or need any help in the future, please don’t hesitate to create a new forum topic. We’ll be more than happy to assist you again.

    Thank you.

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

The ticket ‘Problem with sitemap’ is closed to new replies.