Canonical URLs

If you need to customize the canonical URLs that appear in your metadata or in your XML sitemap you have multiple options:

  • Custom Pages
  • Metadata Field
  • Template Overrides

# Custom Pages

To add support for a custom page with Canonical URL that does not exist in other URL-Enabled Sections, toggle the global plugin setting for "Enable Custom Pages" and a new section will appear on your Sitemaps management page that allows you to add custom URLs to the XML sitemap.

# Metadata Field

To allow overrides to the Canonical URL of a page for an individual entry, enable the "Canonical URL" setting when you set up your metadata field. This will display an additional Canonical URL option for your Metadata field that can be updated by content managers.

# Template Overrides


Overriding Canonical URLs in your templates breaks the relationship with XML Sitemaps and the awareness Sprout SEO has about Canonical URL overrides. To add Custom URLs in a supported way to your XML Sitemaps see the documentation on Custom Pages.

To override the canonical meta value on any given page in your templates, use the craft.sproutSeo.meta tag and set the canonical attribute to the appropriate URL:

{% do craft.sproutSeo.meta({
    canonical: customUrl,
}) %}

{% sproutseo 'optimize' %}
Last Updated: 11/23/2023, 10:32:53 PM