Lighthouse audit canonical · SEO

Document does not have a valid rel=canonical: how to fix it

View raw .md for LLMs / your notes
Quick answer: This audit fails when the canonical link is missing, relative, or points to a redirect. Add one self-referential, absolute https rel=canonical per page that returns a 200 status. It consolidates duplicate-URL ranking signals so Google indexes and ranks the URL you actually want.

Lighthouse fails this audit when your page is missing a <link rel="canonical">, or has one that is malformed, relative, points to a redirect, or conflicts with other signals. The canonical tag tells Google which URL is the authoritative version of a page when several URLs serve similar content.

TL;DR

What does the rel=canonical audit check?

Lighthouse verifies that the page has at most one rel=canonical link, that it is a valid absolute URL, and that it is not obviously broken (empty, relative-only, or pointing at a non-indexable target). It does not judge whether the chosen canonical is strategically correct. That part is on you.

Why does the canonical tag matter for SEO?

Most sites serve the same content under several URLs without realizing it:

Google treats each as a separate URL. Ranking signals (links, engagement) get split across them, and Google may index a parameter-laden variant instead of your clean URL. A correct canonical consolidates all of that into one page.

How do I add a valid canonical tag?

Add a self-referential canonical to <head>:

<head>
  <link rel="canonical" href="https://example.com/audits/canonical-tag" />
</head>

Rules that make a canonical valid and effective:

What are common canonical mistakes?

How do I set the canonical in Next.js, WordPress, or Astro?

Next.js (App Router)

export const metadata = {
  alternates: { canonical: 'https://example.com/audits/canonical-tag' },
};

Next.js (Pages Router)

import Head from 'next/head';

<Head>
  <link rel="canonical" href={`https://example.com${router.asPath.split('?')[0]}`} />
</Head>

WordPress

Yoast SEO and Rank Math emit a self-referential canonical automatically. Do not also hardcode one in the theme: two tags conflict. Override per-page only for genuine duplicates.

Astro

---
const canonical = new URL(Astro.url.pathname, Astro.site).href;
---
<link rel="canonical" href={canonical} />

How do I verify the canonical is valid?

  1. Re-run Lighthouse: the audit should pass.
  2. View source (Cmd+U) and confirm exactly one rel="canonical" with an absolute https URL.
  3. Open the canonical URL directly: it must return 200, not redirect.
  4. Google Search Console → URL Inspection → check "User-declared canonical" matches "Google-selected canonical".

Related audits


Audit your URL at https://lighthouse-md.com.

Audit your page now

Paste your URL, get scores plus a CLAUDE.md plan for Claude Code.

Run audit →