Custom Urls to Sitemap

#720878
Viewing 15 replies - 1 through 15 (of 15 total)
  • Hello, I apologize for the inconvenience you’re facing. To add custom URLs to your Rank Math sitemap, you can use the following filter in your theme’s functions.php file:

    add_filter( 'rank_math/sitemap/providers', function( $external_providers ) {
        $external_providers['custom'] = new RankMathSitemapProvidersCustom();
        return $external_providers;
    });

    You can replace the example URLs with your custom links in the get_sitemap_links() function. Once done, the new sitemap will display your custom links. If you need further assistance, please feel free to ask.

    Sources:
    How to Create a Custom Sitemap and Include It in Rank Math » Rank Math
    How to Configure Sitemaps in Rank Math – Best Settings and Tips

    N E
    Rank Math free

    they are dynamic urls not static

    Hello,

    Thank you for your patience.

    Could you please share some of the URLs so we can check them?

    Meanwhile, here’s the correct filter to add extra URLs to Rank Math’s sitemap:
    https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-urls-in-sitemap

    Hope that helps.

    Hey Team,
    I added this code in my rank-math.php file:-

    /**
     * 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/page_content', function( $content ) {
        for ( $i = 100; $i <= 10000; $i++ ) {
            $content .= "<url>\n";
            $content .= "<loc>https://www.vatcalculate.co.uk/{$i}-plus-vat/</loc>\n";
            $content .= "<lastmod>" . gmdate( 'Y-m-d\TH:i:s+00:00' ) . "</lastmod>\n";
            $content .= "</url>\n";
        }
        return $content;
    });
    

    But these pages are not getting added in the sitemap. I flushed the URLs as well. I am just seeing old pages in sitemap. What is the solution for it?

    Hello,

    You will have to save all the values in an array and then implode and return them as strings. Here is an example of how to do that:

    add_action( 'rank_math/sitemap/page_content', function() {
    	for($i = 100; $i <= 10000; $i++) {
    		$content[] = '<url>
    				<loc>https://rankmath.com/some-custom-url-'.$i.'/</loc>
    				<lastmod>2020-06-10T20:20:20+00:00</lastmod>
    			   </url>';
    			
    	}
    	return implode($content);
    });

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

    https://prnt.sc/aI-Sz0ocAF2y
    You can check the above screen shot. I have added it to rank-math.php.
    I am using generatepress child theme

    I am not seeing any update in my sitemap. You can check here:- https://www.vatcalculate.co.uk/page-sitemap.xml

    Hello,

    Please flush the Sitemap cache by following this video screencast:
    https://i.rankmath.com/pipRDp

    That should fix the issue.

    Please let us know if that does not. We are here to assist.

    It worked for me. Thank You!!!
    I have one doubt though. All the links are shown in one sitemap page only. Will that be problematic from SEO point of view?

    How can I create multiple xml sitemaps, each containing 1000 links
    I am saying this because I want to be prepared for the situation where number of pages exceeds the limit

    Hello,

    You can’t manage the number of URLs per sitemap for the custom URLs. There won’t be any issues with your site’s SEO as Google will be able to discover all the URLs from the sitemap.

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

    Hey Jaideep,
    Generally, there is size limit for sitemap right? But what if the size limit is crossed for a sitemap?

    Hello,

    Thank you for your patience.

    According to Google, all formats limit a single sitemap to 50MB (uncompressed) or 50,000 URLs. If you have a larger file or more URLs, you must break your sitemap into multiple sitemaps.

    However, please note that Google crawls small-sized sitemaps faster. You can also check Google’s guidelines for sitemaps:
    https://developers.google.com/search/docs/advanced/sitemaps/build-sitemap

    With this in mind, Rank math uses the links per sitemap limit to break down sitemaps into smaller parts. We usually recommend the links per sitemap between 200 and 500 only for faster crawling.

    Hope that helps.

    N E
    Rank Math free

    how do we add to show url in sitemap index by sets
    site.com/custom-a
    site.com/custom-b

    bcoz it has custom urls by type

    Hello,

    At the moment, it is not possible to split the custom sitemap. You’ll have to manually do it again by creating a new instance of a custom sitemap.

    However, as long as the sitemap loads perfectly fine and your server can handle the URLs that have been loaded there, there shouldn’t be any issues for Google crawling that sitemap.

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

    N E
    Rank Math free

    i am saying about organizing
    we have custom url patterns
    site.com/a/a-a-a/p
    site.com/a/b-b-b/p
    10 patterns
    every pattern has various slugs …. it has engine libraries for urls

    this are dynamic urls, we have a/ we have /p we want this /a-a-a/

    what do u suggest?
    sitemap index.xml to show custom sitemaps
    we can do custom function to generate urls
    but how it will be inluded or what u have to say?

    Hello,

    You can use the following guide to create a custom sitemap for those URLs: https://rankmath.com/kb/custom-sitemaps/

    To include the dynamic URLs, you will either have to add them manually or figure out a way to automate the generation of the URLs in the filter. This kind of customization falls out of the scope of our support. You will have to hire a professional developer to help you with that.

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

The ticket ‘Custom Urls to Sitemap’ is closed to new replies.