Fix guides · SEO
How to fix “Document doesn't have a valid rel=canonical”
The canonical tag tells search engines which address is the main version of a page. A wrong one can send your ranking to another page, or another site. How to fix it.
- Time to fix
- 10–30 minutes
- Skill needed
- No code
- Who notices
- Everyone searching for you
Why it matters
The same page can often be reached at several addresses: with or without www, with tracking parameters, through different collection paths. The canonical tag names the one search engines should show and credit.
Lighthouse fails the tag when there's more than one, it isn't a valid URL, it points to a different domain or language version, or it points at your home page from another page.
“Search engines select one of the pages as the canonical, or primary, version and crawl that one more.”
Before you start
- In most cases each page's canonical should be its own full address (a self-referencing canonical).
- Make sure only one canonical tag is on the page. Two tools adding one (the platform and an SEO app or plugin) is the most common cause.
- Use the exact domain visitors see, with https and the right www or non-www form.
Fix it on your platform
Shopify
- Themes output the canonical with {{ canonical_url }} in layout/theme.liquid. Check there's exactly one canonical tag, and that no app adds another.
- If the canonical shows a different domain, check your primary domain in Settings → Domains.
WordPress
- WordPress adds a canonical tag to posts and pages itself, and SEO plugins replace it with their own. If you see two, one tool is adding a duplicate; keep the SEO plugin's and check your theme for a hard-coded tag.
- Check Settings → General: the WordPress Address and Site Address should use your real https domain.
Webflow
- Set the Global canonical tag URL in Site settings → SEO to your site's base URL (matching your default domain). Webflow combines it with each page's slug.
- Check page-level custom code for a second canonical tag.
Wix
- Wix creates a self-referencing canonical for every page, and recommends keeping it. If you've customized a page's canonical (SEO basics → Advanced SEO), reset it to the default unless you have a specific reason.
Squarespace Managed by the platform
- Squarespace manages canonical tags itself; for example, it asks Google to index example.com rather than example.com/home. If a canonical is flagged, check code injection for a second canonical tag you added, and check your primary domain setting.
Next.js
- Set metadataBase in the root layout and alternates.canonical in each page, so every page outputs one absolute, self-referencing canonical.
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = await params;
return { alternates: { canonical: `/products/${slug}` } };
}Any other site
- Add exactly one canonical link to each page's <head>, with its full address.
<link rel="canonical" href="https://example.com/products/linen-shirt">Check that it's fixed
- View the page source and search for "canonical": there should be exactly one, pointing at this page's address.
- Re-run your StudioLNC audit: the issue should be gone.
Find every issue like this on your site
Free audit of performance, accessibility, SEO and security, with fixes for your platform.