How to upload an XML sitemap with old URLs?

#564902
  • Resolved Anonymous
    Rank Math free

    Hi, we just did a website migration, and I’d like to add an XML sitemap with our old pages, to our website, but can’t find how to submit it. Could you help? Thank you

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for reaching out to Rank Math support.

    If you want to create a custom sitemap for your website, we have written a comprehensive guide on how to create a custom sitemap and include it in Rank Math here (https://rankmath.com/kb/custom-sitemaps/). Please follow the steps in the guide carefully and make sure to clear your cache after making any changes. You can then submit your custom sitemap to Google Search Console and monitor its indexing status.

    However, if you only want to add extra URLs to the Rank Math generated sitemap, then you can use the filter available here: https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-urls-in-sitemap

    /**
     Filter to add extra URLs to the XML sitemap by type.
     *
     Only runs for the first page, not on all.
     *
     @param string $content String content to add, defaults to empty.
     */
    add_action( 'rank_math/sitemap/{$type}_content', function() {
    return '<url>
    <loc>https://rankmath.com/some-custom-url/</loc>
    <lastmod>2020-06-10T20:20:20+00:00</lastmod>
    </url>';
    });

    Replace {$type} with either post or page depending on if you want the URL to be included in the post or page sitemap – respectively. Instruction on how to add filters to your site is located at the top of the page.

    I hope this helps. If you have any questions or need further assistance, please let me know. I’m happy to help.

    Regards

    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 1 replies (of 1 total)

The ticket ‘How to upload an XML sitemap with old URLs?’ is closed to new replies.