Sitemaps in sub-directory multisite

#198777
  • Resolved Adam Hylands
    Rank Math free

    I have activated RM on the network admin and proceeded through the setup wizard and advanced settings.

    However, I am concerned that the submitted sitemap https://skyhook.tv/sitemap_index.xml only contains 2 pages and not the rest of the multisite sub-directory sites.

    https://skyhook.tv/ is pretty much a landing page which then splits off into the 2 sub-directory sites, skyhook.tv/industrial or skyhook.tv/media.

    how do I add the skyhook.tv/industrial and skyhook.tv/media sub-directories into the one sitemap?

    thanks

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

    Thank you for contacting Rank Math and bringing your concern to our attention.

    Rank Math sitemaps works per website. So, your other sub-directory/sub-sites have their own sitemap in these links since they are part of Multisite:

    https://skyhook.tv/industrial/sitemap_index.xml
    https://skyhook.tv/media/sitemap_index.xml

    However, you can add them to the skyhook.tv only by using this filter:
    https://rankmath.com/kb/filters-hooks-api-developer/#12-filter-to-add-extra-urls-in-the-sitemap

    And here’s our guide on how to apply this on your site:
    https://rankmath.com/kb/wordpress-hooks-actions-filters/

    I hope that helps.

    Thank you, and please don’t hesitate to contact us anytime if you need further assistance with anything else.

    Thanks for this.

    I’m not a proper dev so please bear with me!

    There is no child theme on any of the installations/network so if I create rank-math.php do I still need to add child themes to avoid losing on updates/changes? If so, do I add child theme to each installation or just skyhook.tv (for sitemap XML)?

    Once I have added PHP file (and child themes if needed) I copy code #12:

    /**
    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&gt;
    <lastmod>2020-06-10T20:20:20+00:00</lastmod>
    </url>’;
    });

    Do I need to add every page URL from skyhook.tv/media and skyhook.tv/industrial manually or just these two URLs?
    https://skyhook.tv/industrial/sitemap_index.xml
    https://skyhook.tv/media/sitemap_index.xml

    And can you give me an example of how that would look, editing the code above with one of the URLs I need to add…?

    Thanks for all your help and patience.

    Hello,

    Thanks for getting back. Sorry for the delay and any inconvenience that might have been caused due to that.

    You don’t need to create a rank-math.php file. You will need to insert the code in the functions.php file or a better way is to use the Code Snippets plugin. You can refer to the following article to learn more about using the Code Snippets: https://rankmath.com/kb/wordpress-hooks-actions-filters/#method-1-using-code-snippets-plugin

    I have modified the code for your sitemaps to be added into your main site’s page sitemap. You can use the code given below and insert it on your main site only(skyhook.tv):

    add_action( 'rank_math/sitemap/page_content', function() {
    	return '<url>
    	<loc>https://skyhook.tv/industrial/sitemap_index.xml</loc>
    	<lastmod>2021-05-20T20:20:20+00:00</lastmod>
    	</url>
    	<url>
    	<loc>https://skyhook.tv/media/sitemap_index.xml</loc>
    	<lastmod>2021-05-20T20:20:20+00:00</lastmod>
    	</url>';
    });

    Hope this helps. Let us know if you need any further assistance.

    Thank you for this.
    Just to clarify my actions.
    I have added the code snippet plugin to my network admin.
    I then went to the skyhook.tv installation and added your code, saved and activated.

    So now using the rank math plugin, do I go through the setup wizard and advanced settings again or re-submit the sitemap?

    And to confirm that I should be using Rank Math on my network admin and not having to set it up on each installation? Is that right?

    Thanks again for all your help, amazing service.

    Brian
    Rank Math free

    Hello,

    Thank you for getting back to us.

    Usually, when you install a plugin on a multisite you need to have the plugin installed on the network admin and activate it on the site directory that you need to use it on.

    In this case, if you want to use the code on the main admin site you should insert the code in the theme’s function.php site. Similarly, if you are using the code snippet you should add the code on the main site where the code snippet plugin is activated.

    You do not have to go through the Rank Math setup again after doing this. Once your sitemap is updated simply re-submit it on your GSC for further crawling of your sub-sites.

    When it comes to Rank Math on a multisite, it is multi-site ready and thus you can network activate it and enjoy all benefits. It can as well be used or activated on individual subsites as well.

    This will all depend on how you have set up Rank Math on your multisite. You can check more details here:https://rankmath.com/kb/installing-rank-math-on-a-multisite-environment/

    Hope this is helpful. Please let us know if you have any other questions and we will gladly help.
    Thank 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 5 replies - 1 through 5 (of 5 total)

The ticket ‘Sitemaps in sub-directory multisite’ is closed to new replies.