---
title: "Fix: Add Canonical URL (rel=canonical Tag Missing)"
description: "Add a rel=canonical link in the head so search engines know which URL to index. Syntax, the same host rule, and steps for Next.js, WordPress and Shopify."
url: https://seenlens.com/fixes/add-canonical-url
last_updated: 2026-11-06
---

# Add a canonical URL: how to fix a missing canonical tag

A canonical URL is the address you want search engines to index for a page. Your page lacks one when the head has no rel=canonical link. Add a link with the page's own absolute URL on the same host. Search engines treat it as a strong hint. The change takes about 15 minutes.

By SeenLens. Last updated: 2026-11-06

## What this check tests

SeenLens finds the first `<link rel="canonical">` in the HTML. It resolves a relative address against the final URL of the page and compares the host name with the page's host.

| Result | What SeenLens found |
| --- | --- |
| Warn | No canonical link |
| Fail | The canonical is on a different host, for example `www.example.com` for a page on `example.com` |
| Pass | A canonical on the same host as the page |

## How to confirm the problem

```text
curl -s https://example.com/your-page | grep -i -o '<link[^>]*rel="canonical"[^>]*>'
```

No output means the tag is missing. The embedded scan shows the canonical it found.

## How to fix it

Add one canonical link inside `<head>`. Use an absolute URL, the preferred version of the address, and the same value you list in your sitemap.

```text
<link rel="canonical" href="https://example.com/your-page" />
```

- **Next.js:** set `metadataBase` in the root layout and `alternates.canonical` in the page metadata. Next.js prints the full link (docs updated 2026-08-19).
- **WordPress:** core prints a canonical link on single posts and pages. It does not print one on every archive page. Set the canonical for the others in your SEO plugin or theme.
- **Shopify:** themes print `<link rel="canonical" href="{{ canonical_url }}" />` in `layout/theme.liquid`. Add it if your theme lacks it.
- **Non HTML files such as PDFs:** send a `Link: <https://example.com/file.pdf>; rel="canonical"` response header. Google supports this for web search results.

```text
// app/layout.tsx
export const metadata = { metadataBase: new URL("https://example.com") };

// app/guide/page.tsx
export const metadata = { alternates: { canonical: "/guide" } };
```

## What mistakes make a canonical tag fail?

Google lists these mistakes: placing the link outside `<head>`, using a relative path, adding `hreflang`, `lang`, `media` or `type` attributes to the canonical link, naming different canonical URLs through different methods, using a URL fragment, using robots.txt or `noindex` to choose a canonical, and linking to HTTP duplicates. Google says a canonical declaration is a signal, and it may pick another URL.

### What does a canonical URL mean?

It is the address of the version of a page that you want search engines to index and show. Other addresses with the same content point to it.

### Should every page have a canonical tag?

Google recommends a self referencing canonical on the canonical page itself.

## How to verify the fix

1. Run the curl command. It must print one canonical link with your own URL.
2. In Google Search Console, run URL Inspection and compare the user declared canonical with the Google selected canonical.
3. Run the SeenLens scan and confirm the canonical check passes.

[Run the free SeenLens scan on your page](https://seenlens.com/)

## When can you ignore it?

A canonical on another host is correct when you republish content and want the original source to receive the credit. A page that you keep out of search with `noindex` does not need one. Never use `noindex` to choose a canonical.

## Related checks

- [Page not served over HTTPS](https://seenlens.com/fixes/serve-page-over-https)
- [noindex and nosnippet](https://seenlens.com/fixes/noindex-blocks-ai-answers)
- [Unknown URLs return 200](https://seenlens.com/fixes/soft-404-unknown-urls)
- [Missing H1 tag](https://seenlens.com/fixes/h1-heading-missing)

## Sources

- [Google Search Central: consolidate duplicate URLs](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls) (rel=canonical rules, header form, common mistakes, checked 2026-11-06)
- [Next.js: generateMetadata](https://nextjs.org/docs/app/api-reference/functions/generate-metadata) (alternates.canonical and metadataBase, updated 2026-08-19)
- [WordPress: rel_canonical()](https://developer.wordpress.org/reference/functions/rel_canonical/) (outputs rel=canonical for singular queries, checked 2026-11-06)
- [Shopify: Add SEO metadata to your theme](https://shopify.dev/docs/themes/seo/metadata) (canonical_url in the theme head, checked 2026-11-06)
