Smarketa

Magento 2 Canonical URL: How to Set, Fix and Optimise Canonical Tags

Magento 2 Canonical URL: Setup, Fixes & SEO Guide
  1. Home
  2. Blog
  3. Magento 2 Canonical URL
Magento 2Technical SEOCanonical Tags

Learn how to set Magento 2 canonical URLs, fix duplicate content, add custom canonical tags and optimise product, category and CMS pages for SEO.

Smarketa SEO TeamTechnical SEO
11 min read
/mens/shirts/blue-shirt.html /blue-shirt.html?utm=… /blue-shirt.html?colour=49 CANONICAL/blue-shirt.html <link rel="canonical" href="https://www.example.com/blue-shirt.html" />
In this guide
  1. What Is a Canonical Tag in Magento 2?
  2. Does Magento 2 Add Canonical Tags Automatically?
  3. How to Set Canonical URL in Magento 2 (Built-In Settings)
  4. Magento 2 Canonical Tags: Product, Category and CMS Page Examples
  5. Magento 2 Set Canonical URL for a Custom Page
  6. Magento 2 Custom Canonical Tag: Important Implementation Rules
  7. Magento 2 Add Canonical to CMS Page
  8. Magento Layered Navigation SEO and Filtered URLs
  9. Magento Product Page Duplicate URLs and Product Variants
  10. Canonical Link vs Redirect vs Noindex in Magento 2
  11. Magento 2 Sitemap.xml and Internal Linking Must Match Canonicals
  12. How to Check Magento 2 Canonical URLs in Google Search Console
  13. Common Magento 2 Canonical Problems and Fixes
  14. Magento 2 Canonical URL Best Practices Checklist
  15. Frequently Asked Questions About Magento 2 Canonical URLs
  16. Final Thoughts: Canonical Tags Should Support Your Magento SEO Strategy

A Magento 2 canonical URL tells search engines which version of a page should be treated as the preferred URL when multiple addresses display identical or similar content. Configuring canonical tags correctly helps consolidate ranking signals, manage duplicate product and category URLs, and improve how search engines understand your Magento store.

Magento 2 includes built-in canonical tag settings for product and category pages, but CMS pages, layered navigation, filtered URLs and certain product variations may require additional configuration.

In this guide, you'll learn how to set canonical URLs in Magento 2, add custom canonical tags, troubleshoot common SEO issues and verify your implementation using Google Search Console.

What Is a Canonical Tag in Magento 2?

A canonical tag is an HTML link element placed in the page’s <head>. Its rel="canonical" attribute points to the preferred URL for a duplicate or near-duplicate page. It is a signal rather than a directive: Google may still select a different canonical if the pages and other signals do not support your preference.

HTML
<link rel="canonical" href="https://www.example.com/blue-shirt.html" />

For example, one shirt might be accessible through /blue-shirt.html and /mens/shirts/blue-shirt.html. Both pages could point to /blue-shirt.html if they show the same product. The chosen product URL should normally have a self-referencing canonical too.

Two product URLs, /blue-shirt.html and /mens/shirts/blue-shirt.html, both point their canonical to /blue-shirt.html, which also has a self-referencing canonical Duplicate paths, one preferred URL /mens/shirts/blue-shirt.html /blue-shirt.html DUPLICATE rel="canonical" PREFERRED URL/blue-shirt.html 200 · INDEXABLE self-referencing <link rel="canonical" href="https://www.example.com/blue-shirt.html" />
Figure 1Both product paths show the same shirt, so they point to /blue-shirt.html, and the preferred URL carries a self-referencing canonical.

The SEO benefit is more reliable URL consolidation and less unnecessary crawling of duplicate pages. Duplicate content does not automatically cause a Google penalty, so the priority is controlling indexation and avoiding split signals, rather than trying to “avoid a duplicate content penalty”.

Canonical duplication is not the same as keyword cannibalisation. If two distinct pages target the same search intent, first check whether they should serve different audiences or be consolidated. See our Keyword Cannibalization guide for the broader content-targeting issue.

Does Magento 2 Add Canonical Tags Automatically?

Magento 2 and Adobe Commerce provide native settings to generate canonical link elements for product and category pages. However, these settings are not a complete canonicalisation strategy. They must be enabled for the appropriate store view, and they do not automatically resolve every CMS page, filtered URL, product variant or third-party extension scenario.

You should review generated HTML rather than assume the Magento 2 SEO settings are active. A theme, extension, custom controller or cache issue can change the final canonical link element. For stores with complex templates or multiple extensions, a specialist SEO audit service can help identify conflicts before changing global settings.

How to Set Canonical URL in Magento 2 (Built-In Settings)

  1. Sign in to the Magento Admin panel.
  2. Go to Stores › Settings › Configuration.
  3. Open Catalog › Catalog and expand Search Engine Optimization.
  4. Select the correct website/store view scope, if relevant, and clear Use system value to edit a setting.
  5. Set Use Canonical Link Meta Tag for Categories to Yes and Use Canonical Link Meta Tag for Products to Yes if both page types should output the standard self-referencing canonical. Review your URL architecture before choosing store-wide behaviour.
  6. Click Save Config. Clear relevant caches using your normal deployment process.
  7. Open a product and a category page, view the rendered source and confirm each outputs exactly one appropriate canonical link.

These labels are documented by Adobe, but the final choice depends on your catalogue architecture. For products reachable through multiple category paths, a clean product URL without the category path is often the easiest canonical target.

Do not change production settings without sampling existing URLs and redirects.

Magento 2 Canonical Tags: Product, Category and CMS Page Examples

Page typeExample preferred canonicalWhat to check
Producthttps://www.example.com/blue-shirt.htmlAll duplicate product paths point to the same live product
Categoryhttps://www.example.com/mens/shirts.htmlCategory canonical is not a filter URL by mistake
CMS pagehttps://www.example.com/deliveryCMS page has one self-referencing canonical where appropriate
Tracking parameterhttps://www.example.com/blue-shirt.htmlUTM URL does not become the canonical

Magento 2 Set Canonical URL for a Custom Page

For a custom canonical tag, first confirm that a native feature or extension is not already outputting one. Adding a second canonical link can create conflicting signals. Any override must replace the existing output cleanly and respect store-view URLs, HTTPS and current URL rewrites.

For a developer-managed custom page, Magento’s page configuration head API can be used to add a canonical link. The following PHP fragment is an illustrative implementation inside a custom controller or view model integration, not a standalone drop-in file:

PHP
$page = $this->resultPageFactory->create();
$page->getConfig()->addRemotePageAsset(
    'https://www.example.com/preferred-page',
    'canonical',
    ['attributes' => ['rel' => 'canonical']]
);
return $page;

Your developer should generate the canonical URL using the correct store context rather than hardcoding a production domain, and confirm the method is supported by the Magento version in use. Check that the resulting page has one canonical element and no contradictory canonical generated elsewhere.

Magento 2 Custom Canonical Tag: Important Implementation Rules

  • Choose an absolute HTTPS URL that returns 200 OK, is indexable and serves equivalent primary content.
  • Keep product, category and custom-page canonical logic consistent across all relevant store views.
  • Avoid pointing every paginated, filtered or product-variant URL at a parent page without considering whether its content deserves its own index entry.
  • Do not canonicalise a page to a redirect, broken page, unrelated product or blocked target.
  • Where the duplicate URL is genuinely obsolete, a permanent redirect is usually more appropriate.

Magento 2 Add Canonical to CMS Page

Magento’s native product and category toggles do not provide a universal per-CMS-page canonical field. For pages such as About Us, Delivery or a campaign landing page, your options depend on the installed modules and theme: a reputable SEO extension with per-page canonical fields, or a developer-controlled layout/custom module implementation.

A developer can implement a CMS-page-specific head update using Magento layout configuration and a custom module. The exact layout handle, XML and URL generation depend on the version, theme and CMS page identifier. Validate the output on the intended CMS page only, so a shared layout update does not accidentally apply one canonical URL to every CMS page.

If the CMS page is unique and indexable, use a self-referencing canonical. If it reproduces an established permanent page, canonicalise to that page only when the main content is materially equivalent. A 301 redirect may be better if the duplicate page no longer needs to be accessible.

Magento Layered Navigation SEO and Filtered URLs

Layered navigation is a common source of duplicate content in Magento. Size, colour, brand, price and sorting parameters can generate many category URL combinations. Some filtered pages are valuable landing pages; others simply rearrange or narrow the same listings.

For non-strategic filter combinations with substantially overlapping content, a canonical to the main category may be appropriate. For a filter page with genuine search demand, a stable URL, unique merchandising and useful copy, consider making it an independently indexable landing page with its own canonical. Canonical tags alone do not prevent search engines from crawling a large parameter space.

Layered navigation decision: non-strategic filter combinations canonicalise to the main category, while filter pages with genuine search demand become indexable landing pages with their own canonical Filtered URLs: consolidate or index? CATEGORY + FILTERS/mens/shirts.html?colour=… Non-strategic filter Substantially overlapping content ?size=m&sort=price Canonical → main category Filter with search demand Stable URL, unique copy /mens/blue-shirts.html Indexable, own canonical
Figure 2Layered navigation: consolidate non-strategic filter combinations to the main category, and give filter pages with genuine search demand their own indexable URL.

For stores with extensive filters, combine canonical planning with crawlable navigation rules, sensible parameter handling and an indexation policy. These decisions should also align with your category-page targeting. Our Category Page SEO guide explains why valuable category URLs need distinct search intent and content, while our Magento SEO service page covers layered-navigation issues across larger catalogues.

Magento Product Page Duplicate URLs and Product Variants

Duplicate product URLs often appear when a product is accessible through multiple category routes or URL rewrites. Ensure the canonical points to the chosen product URL and that internal links favour that same address.

Variants need a different decision. If size or colour variants have practically identical page content, consolidating them to a parent product may make sense. If variants have distinct search demand, useful differentiating content and their own dedicated landing pages, automatically canonicalising all of them to one parent could remove valuable pages from search results. Apply the policy based on the actual product experience, not a blanket rule.

MethodWhen to use itMain consideration
rel=canonicalDuplicate or near-duplicate URLs should remain accessibleGoogle treats it as a signal, not an order
301 redirectAn old or duplicate URL should no longer be accessible separatelyVisitors and crawlers are sent to the preferred URL
noindexA page should not appear in search at allDo not use as a substitute for canonicalisation
robots.txt disallowPrevent crawling of chosen URL patterns when appropriateBlocked pages may be unable to pass a visible HTML canonical signal

An SEO policy should distinguish index vs noindex Magento decisions from canonicalisation decisions. Do not use noindex simply to force Google to pick another canonical. Likewise, avoid blocking a duplicate URL in robots.txt if Google needs to crawl the page to discover its canonical annotation.

Magento 2 Sitemap.xml and Internal Linking Must Match Canonicals

Keep the Magento 2 sitemap.xml focused on preferred, indexable URLs. If your sitemap lists one URL but its canonical points elsewhere, you give conflicting signals. The same principle applies to breadcrumbs, category links, product recommendations and other internal links: wherever practical, link directly to the chosen canonical URLs.

A broader technical review should also check metadata, URL rewrites and architecture. Strong canonical signals work best alongside sound on-page optimisation, clear category targeting and useful content. This is especially important in an Ecommerce SEO service, where indexable product and category URLs should support buying-intent searches. A focused SEO content strategy can then build relevance around the pages you actually want indexed.

How to Check Magento 2 Canonical URLs in Google Search Console

  1. Inspect the preferred product, category or CMS URL using Google Search Console URL Inspection.
  2. Compare User-declared canonical and Google-selected canonical, where available.
  3. Inspect representative duplicates, including category-path products, query-parameter URLs and filtered pages.
  4. Check whether the canonical target returns 200, is indexable, appears in the intended sitemap and has consistent internal links.
  5. Use a crawler to find missing, duplicate, non-self-referencing or conflicting canonicals across templates.
  6. After fixing the problem, request re-indexing for priority URLs if appropriate and monitor results. Google may take time to reassess canonical clusters.

A different Google-selected canonical does not always mean there is an error. Assess whether the selected URL is genuinely a better representative of the duplicate set before changing site configuration.

Common Magento 2 Canonical Problems and Fixes

ProblemLikely causeRecommended action
Canonical tag is missingNative toggle off, unsupported template or custom overrideCheck store scope and generated head output
Two canonical tagsTheme or extension adds another tagRemove duplicate output at its source
Canonical points to old URLStale rewrite, cache or version-specific bugCheck rewrites, cache, patches and update behaviour
Every filter points to categoryOverly broad navigation ruleSeparate indexable landing pages from duplicate filters
Google selects a different URLSignals conflict or pages differ substantiallyAlign internal links, sitemaps, redirects and page content
CMS page has no canonicalNo native per-page implementationAdd a controlled CMS-specific solution

Adobe has documented a quality patch for a category canonical that failed to update following a URL-key change in affected versions. Before customising core behaviour, check whether your Magento build is affected and whether a supported patch is available. Issues that persist across templates often call for a wider magento technical seo review of generated URLs, routing and extensions.

Magento 2 Canonical URL Best Practices Checklist

  • Enable product and category canonical settings where appropriate and verify final rendered output.
  • Use one valid absolute canonical URL per HTML page and consider self-referencing canonicals.
  • Make canonical targets indexable, accessible and content-equivalent.
  • Give high-value filter pages and product variants their own indexation strategy.
  • Keep XML sitemaps, internal links and canonical targets aligned.
  • Use permanent redirects for obsolete URLs rather than relying on canonical tags alone.
  • Review canonicals after migrations, URL-key changes, theme releases and extension updates.
  • When migrating from Magento 1 or rebuilding an Adobe Commerce store, update canonical targets alongside redirects and sitemaps. Use our Magento migration SEO guide as a broader launch checklist so the new URLs send consistent signals from day one.
  • Audit Google-selected canonicals periodically, especially for revenue-driving product and category pages.
FAQs

Frequently Asked Questions About Magento 2 Canonical URLs

The rel=canonical tag identifies the preferred URL among pages with the same or very similar main content. Magento can generate these tags on products and categories when the relevant settings are enabled; Google still makes the final canonical selection.

Go to Stores > Settings > Configuration > Catalog > Catalog > Search Engine Optimization and enable the appropriate product or category canonical options. Use a page-specific customisation or compatible extension for cases the native settings do not cover.

They help clarify the preferred product or category URL where multiple routes show equivalent content, making indexation signals more consistent. They are especially useful for category paths, URL parameters and duplicate product routes.

Start by identifying duplicated URLs and deciding which ones should remain indexable. Use canonicals for near-duplicates that must remain accessible, redirects for obsolete URLs, and distinct content for important standalone pages. Then align sitemaps and internal links.

Magento 2 has built-in product and category canonical settings, but their output depends on configuration. CMS pages, filters and custom implementations may need separate rules or development.

Developers can add a canonical page asset through Magento’s page configuration APIs in a custom module or controller. The implementation must use the correct store URL and avoid outputting a second, conflicting tag.

There is no universal best extension. Look for compatibility with your Magento version, per-page CMS controls, configurable filtered URL rules, multi-store support, safe canonical overrides and reliable maintenance. Test it on staging and confirm it produces one canonical tag per page.

Self-referencing canonicals are generally useful on indexable, canonical HTML pages, but not every URL should be indexed. Duplicates may point elsewhere, while intentionally non-indexable pages require a separate strategy.

Final Thoughts: Canonical Tags Should Support Your Magento SEO Strategy

Magento 2 canonical URLs are a small piece of code with a major role in managing large ecommerce catalogues. Start with the native settings, audit real product and category URL patterns, and apply custom rules only where your architecture needs them. The goal is a clear set of indexable pages, not the indiscriminate consolidation of every URL.

If product variants, layered navigation or custom modules have created conflicting signals, a technical audit can show which pages are worth indexing and which should consolidate. Smarketa’s Magento SEO team can help prioritise the fixes that matter to organic product and category visibility.

Mariam Mirzoyan is the SEO Team Lead at Smarketa, with strong expertise across technical SEO, on-page optimisation, content strategy, and organic search growth. She manages SEO campaigns from strategy through execution, helping businesses improve visibility, strengthen keyword performance, and generate more qualified traffic from search. Her approach is focused on practical improvements, clear priorities, and long-term results.

Leave a Reply

Your email address will not be published. Required fields are marked *