1

I have a custom generated sitemap which I'd like to append to my SEOmatic sitemap.xml file.

Is this possible?

I suppose the simple alternative would be to just add an extra sitemap to Google Search Console?

2

This has been added in SEOmatic 3.1.36 as per this release announcement tweet

You can do it via the GUI in SEOmatic -> Site Settings -> Sitemap: https://github.com/nystudio107/craft-seomatic#additional-sitemaps

Additional Sitemaps

...or you can do it via plugin:

use nystudio107\seomatic\events\RegisterSitemapsEvent;
use nystudio107\seomatic\models\SitemapIndexTemplate;
use yii\base\Event;
Event::on(SitemapIndexTemplate::class, SitemapIndexTemplate::EVENT_REGISTER_SITEMAPS, function(RegisterSitemapsEvent $e) {
    $e->sitemaps[] = [
        'loc' => $url,
        'lastmod' => $lastMod,
    ];
});
4
  • No worries! Let me know how you go. – andrew.welch Dec 11 '18 at 23:44
  • Your update works great. If I had to change anything I'd like to be able to include a {{SiteUrl}} variable (or similar) in the sitemap path. – Wayde Christie Dec 17 '18 at 0:38
  • File a FR for it! github.com/nystudio107/craft-seomatic/issues -- should be easy to do – andrew.welch Dec 17 '18 at 2:27
  • Also mark this as the accepted answer if you're satisfied with it, so SE can stay happy :) – andrew.welch Dec 17 '18 at 2:28
2

This is actually pretty simple...

If you navigate to SEOmatic → Site Settings → Miscellaneous, you'll see a table at the bottom of the page where you can input custom sitemap urls.

SEOmatic Miscellaneous Site Settings

Once you add a url in here and save it, it will get added to a custom index sitemap that is included at the bottom of your main index sitemap:

/sitemaps/1/sitemap.xml

<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  ...
  <sitemap>
    <loc> http://site.test/sitemaps/1/global/custom/1/sitemap.xml </loc>
    <lastmod> 2018-11-16T10:06:31-05:00 </lastmod>
  </sitemap>
</sitemapindex>

/sitemaps/1/global/custom/1/sitemap.xml

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc> http://site.test/custom.xml </loc>
    <lastmod> 2018-12-07T14:26:25-05:00 </lastmod>
    <changefreq> weekly </changefreq>
    <priority> 0.5 </priority>
  </url>
</urlset>

for more info → https://github.com/nystudio107/craft-seomatic#additional-sitemap-urls

3
  • 1
    You can also do it programmatically via PHP as well. Same link that Jalen mentioned. – andrew.welch Dec 7 '18 at 22:13
  • Thanks Jalen - I did see this function but it looks like it only supports adding individual URLs - not other sitemaps. Ideally I want to add a new sitemap to the sitemapindex. I'm not sure whether Google will parse a sitemap.xml which is supplied as an individual URL rather than as part of a sitemapindex. Perhaps a feature request is in order :) – Wayde Christie Dec 9 '18 at 22:40
  • Sorry, I misunderstood everything here... it looks like what you want is the ability to add additional sitemaps generated externally, and what SEOmatic lets you do is add URLs to one additional custom sitemap. Yep, file a FR for this one @WaydeChristie – andrew.welch Dec 10 '18 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.