Yoast SEO
[Plugin: WordPress SEO by Yoast] Include subsites in main blog's sitemap on multisite network (4 posts)

  1. PaulMighty
    Posted 4 years ago #


    I am running a multisite/network install of WordPress using the Yoast WordPress SEO plugin. I'm wondering if it is possible to generate links to subsite sitemaps from the main blog/site sitemap? This way the subsites would be included with all the other category and post types like this in the main blog/site's sitemap_index.xml:




  2. daffscat
    Posted 3 years ago #


    I'm looking for the same information. Any news or thoughts since your last post?.

    Ours subsites are independent but fully integrate into our main network (same header, same main menu, same footer, ...). For us it makes sense that subsites also appear as part of our main blogs and be included from the main blog/site sitemap.

    I am not an expert in sitemap, but the way I imagine web crawler works is that when looking for a sitemap (or robots.txt), it first looks into the web server's root directory, then follows directives (either sitemap.xml or robots.txt). So without explicit directive (http://www.domain.com/subsite-1/sitemap_index.xml) from the main blog sitemap.xml to look at for subsites sitemap.xml , how a web crawler will find it ?.

    Could someone please enlighten me ?


  3. PaulMighty
    Posted 3 years ago #

    I was snooping around in the plugin code, which lead me to finding these two links, which may provide clues to adding custom sitemap entries:

    On line 213 of wordpress-seo/inc/class-sitemaps.php you'll find:
    $this->sitemap .= apply_filters( 'wpseo_sitemap_index', '' );

    Seeing this and looking at link #2 above, I believe we can hook into the sitemap by creating an array and passing it by…
    add_filter( 'wpseo_sitemap_index', array( $this, 'add_to_index' ) );


  4. PaulMighty
    Posted 3 years ago #

    Successfully tested by adding the following to functions.php:

    function add_sitemap_custom_items(){
    	$sitemap_custom_items = '<sitemap>
    	return $sitemap_custom_items;
    add_filter( 'wpseo_sitemap_index', 'add_sitemap_custom_items' );

    Now, if only I knew of a way to filter OUT specific items that are auto-generated by the plugin in addition to using the plugin's options to exclude Post Types and Taxonomies. It would be great if these were options from within the plugin's admin page, but it's already an incredibly helpful plugin, so I'm not complaining.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic