Automatically Add Yoast Sitemap to Dynamic Robots.txt

Adding a sitemap to your robots.txt is a good step to increasing the crawl rate of your site if your site is still young, even with older sites this is still a good step to take. In this guide, we will show you how to add the sitemap from Yoast SEO to the dynamic sitemap of all sites on your WordPress Multisite. This works with standard multisite installations and setups using domain mapping.

You can also follow this guide to add global rules to all your networks robots.txt files, you could expand on this as much as you want and even add rules to specific sites using a conditional statement with the current blog ID $site_id = get_current_blog_id();.

In this guide, we will just show you how to add a sitemap link to all sites robots.txt file. You will need to create a Must-Use Plugin (MU-Plugin) for your network, you could also use the Code Snippets plugin but I suggest an MU-Plugin.