# Document does not have a valid rel=canonical: what it means and how to fix it

**Audit ID:** `canonical` · **Category:** SEO

<!--QA-->
> **Quick answer:** Lighthouse flags a non-canonical URL when the rel=canonical link is missing, relative, or points to a redirect. Fix the canonical missing error by adding one self-referential, absolute https rel=canonical per page that returns 200. It consolidates duplicate-URL ranking signals onto your preferred URL.
<!--/QA-->

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:** No valid `<link rel="canonical">` in `<head>`, or it points somewhere Google can't trust.
- **Why it matters:** Without it, duplicate URLs (tracking params, trailing slashes, http vs https, www vs apex) split ranking signals and Google may index the wrong one.
- **Fix:** Add one self-referential, absolute, `https` canonical per page that returns `200`.

## 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.

## What is a "non-canonical URL"?

"Non-canonical URL" is how Lighthouse and other SEO tools (Bing Webmaster Tools, Screaming Frog, Ahrefs) phrase the same problem the `canonical` audit catches: your page has no valid `<link rel="canonical">`, or the tag is relative, empty, or points at a URL that does not actually serve the page (a redirect, a 404, or a `noindex` target). Tools also call this **"missing canonical tag"**, **"canonical missing"**, **"canonical is missing"**, or **"no canonical link tag found on your homepage"**, all the same underlying issue.

The fix is identical to passing Lighthouse's `canonical` audit: add one self-referential, absolute `https` `rel=canonical` per page that returns `200`. Without it, Google may index a parameter-laden or duplicate version of your URL instead of the one you want to rank.

## Why does the canonical tag matter for SEO?

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

- `https://example.com/page` and `https://example.com/page/`
- `?utm_source=...` and other tracking parameters
- `http://`, `https://`, `www.`, and apex variants
- Paginated or filtered views of the same list

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>`:

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

Rules that make a canonical valid and effective:

- **Absolute URL.** Use the full `https://` URL, not `/audits/canonical-tag`.
- **Self-referential by default.** Each page points at its own preferred URL. Only point elsewhere when the page is a genuine duplicate.
- **Resolve to 200.** The canonical target must be indexable: no redirect, no 404, not blocked by robots.
- **One per page.** Multiple conflicting canonicals make Google ignore all of them.
- **Consistent with other signals.** The canonical, the sitemap URL, internal links, and any `hreflang` entries should all agree.

## What are common canonical mistakes?

- **Canonical points to a redirect.** If `/page` canonicalizes to `/page/` and `/page/` 301s back, Google sees a loop and ignores it.
- **Relative URLs.** Some frameworks emit `href="/page"`. Always render the absolute URL.
- **Every page canonicalizing to the homepage.** A frequent CMS misconfiguration. It tells Google your inner pages don't exist.
- **Canonical to a `noindex` page.** Contradictory: you're saying "rank this" and "don't index this."
- **Mismatched protocol or host.** Canonical says `http://www.` while the live page is `https://` apex.
- **Parameter URLs canonicalizing to themselves.** `?utm_source=twitter` should canonicalize to the clean URL, not to the tracked one.

## How do I fix canonical issues?

"Canonical issues", "canonical issue", or "canonical error" is how site auditors like Semrush, Ahrefs, Sitebulb, and Screaming Frog label the whole family of problems the Lighthouse `canonical` audit catches. Whatever the tool calls it, the fix is the same short checklist:

1. **No canonical at all** · add one self-referential, absolute `https` canonical to `<head>`.
2. **Canonical points to a redirect or 404** · point it at the final URL that returns `200`.
3. **More than one canonical tag** · keep exactly one; conflicting tags make Google ignore all of them.
4. **Canonical disagrees with the sitemap or internal links** · pick one preferred URL and use it everywhere.
5. **Conflicting hreflang and rel=canonical** · every language variant must canonicalize to itself, not to another language's URL. A page that declares hreflang alternates while its canonical points elsewhere sends Google contradictory signals; see the [hreflang audit](/audits/hreflang-tag) for the full return-link rules.

Re-run Lighthouse or your site auditor after each change. If the canonical error persists, check whether a plugin or framework is injecting a second tag over the one you added.

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

### Next.js (App Router)

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

### Next.js (Pages Router)

```jsx
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

```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

- [Document does not have a meta description](/audits/meta-description), the search snippet
- [Document does not have a title element](/audits/document-title), the primary SEO signal
- [Does not use HTTPS](/audits/use-https), protocol consistency feeds canonical correctness
- [Alternate page with proper canonical tag](/search-console/alternate-page-with-proper-canonical-tag), the Search Console status you see when a canonical tag is working

---

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