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.
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
Canonical tag exists with an absolute https:// URL
Canonical tag is missing
Canonical href is empty
Canonical href is not an absolute https:// URL (relative path or http://)
Edge cases
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.
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.
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.
Query parameters: the canonical should not include tracking parameters (?ref=, ?utm_source=). Point to the clean URL.
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
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.