Sitemaps

Advanced SEO generates sitemaps for all of your collections and taxonomies. The sitemaps are organized in a sitemap index which can be accessed at site.com/sitemap.xml.

Disable Sitemaps

You may globally disable the sitemap feature by setting enabled to false in the config:

'sitemap' => [
    'enabled' => false,
]

Disabling Collections & Taxonomies

There are a couple of ways to disable a collection or taxonomy from generating sitemaps.

Disabled Collection or Taxonomy

Sitemaps won't be created for any collection or taxonomy that has been disabled in the config:

'disabled' => [
    'collections' => ['people', 'subscriptions'],
    'taxonomies' => ['nations'],
],

Excluded collections and taxonomies

Sitemaps won't be created for any collection or taxonomy that has been configured to be excluded from the sitemap in the Indexing site defaults:

Enabled Noindex

Sitemaps won't be created if Noindex has been enabled in the Indexing site defaults:

Excluding entries and terms

There are a couple of factors that determine if an individual entry or term will be excluded from the sitemaps.

Disabled Sitemap

An entry or term will be excluded from the sitemap if the toggle is disabled:

Enabled Noindex

An entry or term will be excluded from the sitemap if Noindex has been enabled:

Canonical URL

An entry or term will be excluded from the sitemap if the canonical URL is anything else but Current Entry or Current Term. In the following example, the entry will be excluded from the sitemap:

Caching

Sitemaps are cached for 60 minutes and cleared whenever a collection, taxonomy, entry, or term is saved or deleted. The cache is also cleared whenever you save an SEO default.

You may change the cache expiry in the config:

'sitemap' => [
    'expiry' => 60,
]

Custom Sitemaps

Custom sitemaps are a great tool to add any Statamic or Laravel route to Advanced SEO's sitemaps. Follow this example to learn how to create a sitemap:

use Aerni\AdvancedSeo\Facades\Sitemap;

// Create a new sitemap URL.
$signIn = Sitemap::makeUrl('https://statamic.com/sign-in');

// You may also add optional attributes.
$seller = Sitemap::makeUrl('https://statamic.com/seller')
    ->lastmod(now())
    ->changefreq('daily')
    ->priority('1.0');

// Create a sitemap and add the items to it.
$sitemap = Sitemap::make('user')
    ->add($signIn)
    ->add($seller);

// Add your new custom sitemap to the sitemap index.
Sitemap::add($sitemap);

This code has to go in a Service Provider to make sure the sitemaps are created and added with every request.

Last updated