All rules
critical
Rule: canonical-urlWeight: 10/100

Rule: canonical-url

The canonical URL tells search engines which version of a page is the 'original.' Without it, Google may index /page, /page/, /page?ref=twitter, and /PAGE as four separate pages — splitting your ranking signals across duplicates. At weight 10/100, this is the heaviest single rule in Indxel. It's critical for a reason: duplicate content is the silent killer of SEO.

Run the check
$ npx indxel check
Look for canonical-url in the output

What it checks

Indxel looks for a <link rel="canonical" href="..."> tag in the HTML head. The rule performs three checks: (1) the tag exists, (2) the href is non-empty, and (3) the href starts with 'https://'. Relative URLs like '/about' fail. HTTP URLs like 'http://example.com/about' fail. Only absolute HTTPS URLs pass. In Next.js, this is generated from the alternates.canonical field in your metadata export.

Thresholds

PASS

Canonical tag exists with an absolute https:// URL

ERROR

Canonical tag is missing

ERROR

Canonical href is empty

ERROR

Canonical href is not an absolute https:// URL (relative path or http://)

Edge cases

1

Trailing slashes matter: https://example.com/about and https://example.com/about/ are different URLs. Your canonical should match your preferred format. Indxel does not enforce a trailing-slash policy — it only checks that a canonical exists and is absolute.

2

Self-referencing canonicals (pointing to the same URL) are the most common and recommended pattern. Cross-domain canonicals (pointing to a different domain) are valid but less common.

3

If you have both a canonical tag and a redirect, the redirect takes precedence. But having both is good practice for cases where the redirect fails.

4

Query parameters: the canonical should not include tracking parameters (?ref=, ?utm_source=). Point to the clean URL.

5

Next.js metadataBase: if you set metadataBase in layout.tsx, alternates.canonical can be a relative path and Next.js will prepend the base URL. Indxel checks the final rendered tag, so it sees the absolute URL.

Configuration

indxel.config.ts
// indxel.config.ts
import { defineSEO } from "indxel";

export default defineSEO({
  rules: {
    "canonical-url": true, // enabled by default (critical)
  },
});

// Centralize canonical generation:
// src/lib/metadata.ts
export function generatePageMetadata({ title, description, path }) {
  return {
    title,
    description,
    alternates: {
      canonical: `https://example.com${path}`,
    },
  };
}

Frequently asked questions

Why does Indxel require https:// and not allow relative URLs?

Relative canonical URLs are technically valid HTML, but they're error-prone. A relative canonical on a page served from a CDN subdomain could point to the wrong origin. Absolute HTTPS URLs are unambiguous and are Google's recommended practice.

What happens if the canonical URL points to a different page?

Google treats it as a signal that the other page is the 'original' and may de-index the current page. This is useful for syndicated content or paginated pages, but a misconfigured canonical can accidentally de-index important pages. Indxel checks presence and format but does not validate that the canonical points to the correct URL.

Is 10/100 weight too much for one rule?

No. Duplicate content is one of the most damaging and most common SEO problems. A missing canonical on a large site can create hundreds of duplicate URLs. The weight reflects the real-world impact.

Related rules

title-present

critical — 5/100

description-present

critical — 5/100

robots-not-blocking

optional — 5/100

Validate your SEO now

$npx indxel check
Get startedBrowse all rules
Indxel

SEO validation that runs in your terminal and blocks bad deploys.

GitHubnpm

Product

  • Documentation
  • Pricing
  • Plus Plan
  • CI/CD Guard
  • Indexation
  • Free Tools
  • Blog

Comparisons

  • vs Semrush
  • vs Ahrefs
  • vs Moz
  • vs Screaming Frog
  • All comparisons

Integrations

  • Vercel
  • GitHub Actions
  • Netlify
  • Docker
  • All integrations

Resources

  • Frameworks & use cases
  • Next.js
  • For freelancers
  • For agencies
  • SEO Glossary

Built with care. MIT Licensed.

PrivacyTermsLegalContact