What a canonical does
A canonical tells Google which URL you want indexed when several URLs show the same content: tracking parameters, sort orders, print versions, http and https, www and bare domain. It goes in the HTML <head> as a <link> tag with rel=canonical, or for PDFs and other files in a Link response header. Google treats it as a strong hint, not a rule.
Canonical tag example
A shop lists the same shoes at https://example.com/shoes?sort=price and https://example.com/shoes. This line in the <head> of both URLs tells Google to index the version without the parameter:
On /shoes itself the tag points to its own URL. That is a self-referencing canonical, and Google's documentation recommends one on every canonical page. For a PDF or another file without HTML, send the same thing as a response header:
Rules from Google's canonical documentation:
- Use the full URL with
https://and the host, not/shoes. Google accepts relative URLs but advises against them: if a test copy of the site gets crawled, its pages then point to themselves. - Google only reads the tag in the
<head>, so keep at least the head valid HTML. A canonical in the body is ignored. - Don't use a URL with a
#fragment as the canonical. - Don't use
noindexto pick between duplicates on your own site. It removes the page from Search completely. - On a CMS you rarely edit the HTML. Look for the canonical field in its SEO settings or SEO plugin.
Canonical mistakes that cost rankings
- Every page canonicalised to the home page, usually from a template or plugin setting.
- Canonicals to a staging host, the
http://version or a URL that redirects. - A canonical to a page that returns 404 or has
noindex. Google then ignores the hint and picks a canonical itself. - Two different canonicals on one page, for example one from the theme and one from an SEO plugin. Google ignores both.
Canonical and noindex on the same page
A canonical says "this page is a copy, index that URL instead". noindex says "keep this page out of search". Google's canonical documentation is clear about which job belongs to which: it doesn't recommend noindex "to prevent selection of a canonical page within a single site", because "it will completely block the page from Search". How the combinations play out:
| Setup | What it tells Google | What to do |
|---|---|---|
noindex + canonical to the page itself | No conflict: the page stays out of search. The canonical does nothing here | Fine for pages you want hidden. If the page should rank, the noindex is the bug: often a plugin setting or a leftover from staging |
noindex + canonical to another URL | Two instructions at once: "drop this page" and "this is a duplicate of that one". Google doesn't document which signal wins | Pick one. A duplicate (filter, parameter, print version) gets only the canonical. A page with no value in search gets only noindex |
Canonical to a URL that has noindex | "Index that page instead", but that page refuses to be indexed. Neither URL may show up | Point the canonical to an indexable URL that returns 200, or remove the noindex from the target |
The checker above flags all three: it reads the meta robots tag and X-Robots-Tag header of your URL, and fetches the canonical target to look for noindex there. The same documentation also warns against declaring one canonical in the sitemap and a different one in the page, and against using robots.txt for canonicalisation.
Canonical URL in Next.js
In the Next.js App Router you don't write the tag yourself. You set alternates.canonical in the metadata export or in generateMetadata, and Next.js renders the tag. A relative path needs metadataBase, usually set once in the root app/layout.js:
With metadataBase: new URL('https://example.com') in the root layout, that renders https://example.com/blog/my-post. The traps, from the Next.js metadata reference:
| Setup | What happens | What to do |
|---|---|---|
alternates: { canonical: '/' } in the root layout | Metadata is merged from the root layout down to the page, and a page that doesn't set alternates inherits the layout's. Every such page declares the home page as its canonical | Set only metadataBase in the root layout. Set alternates.canonical in each page or in generateMetadata |
The layout sets alternates.canonical, the page sets only alternates.languages | The merge is shallow: the page's alternates object replaces the layout's as a whole, so the canonical is gone | Set the canonical and the languages together in the same alternates object |
Relative canonical, no metadataBase | The build fails with an error, so this one rarely reaches production | Add metadataBase with your production origin. Using a preview or staging host there puts that host in every canonical |
Paste a few page types into the checker above (home, a blog post, a product, a page with a parameter). If they all show the same canonical, the root layout is the cause. The Pages Router has no metadata export: the tag goes into next/head on each page.
Canonical URL in Yoast SEO
On WordPress with Yoast SEO you rarely need to touch the canonical: Yoast adds one to every post, page and archive, pointing to that page's own URL. To point a page somewhere else, open it in the editor, go to the Advanced tab in the Yoast SEO sidebar or meta box and fill in Canonical URL. It works the same on categories and tags. What trips people up, from Yoast's own help pages:
| What you see | Why | What to do |
|---|---|---|
| No canonical at all on a page | Yoast outputs no canonical on a page set to noindex. The checker above shows the noindex next to the empty canonical | If the page should rank, remove the noindex in the same Advanced tab and the canonical comes back. If it should stay hidden, nothing is wrong |
| A custom canonical that doesn't work | Yoast wants the full address in the field: https://, and www or not, as on the live site | Paste the URL from the browser's address bar of the target page, then run it through the checker to see that it returns 200 without a redirect |
| No Advanced tab for some users | By default only editors and administrators see it | Yoast SEO > Settings > Site basics: switch off Restrict advanced settings for authors, if you want authors to set canonicals |
No canonical on any page, and no noindex | Code can switch the tag off: a theme or plugin that returns false from Yoast's wpseo_canonical filter removes it everywhere | Search the theme's functions.php and custom plugins for wpseo_canonical |
| Two canonicals on one page | The theme or a second SEO plugin prints its own tag next to Yoast's. Google ignores both when they differ | Keep one source. The checker lists every canonical it finds, so you see both |
Canonical URL on Shopify (canonical_url)
Shopify themes print the canonical with the Liquid object canonical_url. Shopify's own Dawn theme has this line in layout/theme.liquid:
The Liquid reference only says it is "the canonical URL for the current page". What it returns, checked on Shopify's Dawn demo store on 2026-10-21:
| URL you open | Canonical Shopify prints | What it means |
|---|---|---|
/collections/bags/products/tote, /products/tote?variant=123, /products/tote?utm_source=x, /products/TOTE | /products/tote | Every copy of a product points to the one product URL. These are the URLs Search Console lists as Alternate page with proper canonical tag: nothing to fix |
/collections/bags?sort_by=price-ascending, /collections/bags?filter.v.availability=1 | /collections/bags | Sorted and filtered views point to the plain collection. Shopify's default robots.txt also blocks sort_by URLs and URLs with two or more filters |
/collections/bags?page=2, also with sort_by added | /collections/bags?page=2 | Each page of a collection keeps its own canonical, which is what Google asks for on paginated lists |
/collections/bags/tote (a tag filter) | Itself | Each tag gets its own indexable page. The default robots.txt only blocks combinations of two or more tags (/collections/*+*) |
/search?q=bag | Itself | Search result pages are their own canonical, and the current default robots.txt doesn't block /search. If they show up in Search Console, add a noindex to the search template in theme.liquid |
A headless store (Hydrogen) at /collections/all/products/x | Whatever the store's code writes | Hydrogen doesn't use Liquid, so canonical_url doesn't apply. On the Hydrogen store we checked, the collection URL of a product declared itself as canonical instead of /products/x |
If a Liquid theme shows a different canonical than this table, the theme or an app has replaced {{ canonical_url }}: search theme.liquid and snippets for canonical. Two canonicals on one page usually means an SEO app adds a second one.
If Search Console already says Duplicate, Google chose different canonical than user, read the guide to that status; for Duplicate without user-selected canonical, read this one. To check noindex, robots.txt and the redirect chain of the same URL, use the noindex checker.
We fetch the URL, and the canonical URL if it is a different one, as NoindexWatchBot. JavaScript is not run, so a canonical added by a script is not seen; Google sees it only after rendering. Results are not stored.