HTMLCanonical URLs & hreflang

Canonical URLs and hreflang

When the same content is reachable through more than one URL, search engines need to know which one is the "real" version to index and rank. The canonical link tag answers that question; hreflang answers the related question of which language/region version to serve.

The canonical link tag

HTML
<link rel="canonical" href="https://example.com/blog/html-guide" />

Placed in <head>, this tells crawlers: "no matter what URL you found this content at, treat this href as the authoritative one." Any ranking signals (like backlinks) accumulated by duplicate URLs get consolidated onto the canonical URL.

Common duplicate-content scenarios

Scenario

Example duplicates

Tracking parameters

example.com/guide vs example.com/guide?utm_source=newsletter

Trailing slash variants

example.com/guide vs example.com/guide/

HTTP vs HTTPS

http://example.com/guide vs https://example.com/guide

www vs bare domain

www.example.com/guide vs example.com/guide

Sort/filter query strings

example.com/shop?sort=price vs example.com/shop

In every case above, a single canonical tag pointing at the preferred URL (e.g. https://example.com/guide) tells search engines to treat them all as one page.

hreflang for multi-language sites

hreflang link tags tell search engines which URL serves which language/region, so the right version is shown to the right searcher — without being flagged as duplicate content.

HTML
<link rel="alternate" hreflang="en" href="https://example.com/en/guide" />
<link rel="alternate" hreflang="de" href="https://example.com/de/guide" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en/guide" />
  • Each language variant should list hreflang tags for every other variant, including itself — a full, matching set on every page.

  • x-default marks the fallback version shown when no other hreflang matches the visitor's locale.

  • hreflang values combine an ISO language code (en) with an optional region code (en-GB, en-US).

Common canonical mistakes
  • Pointing the canonical tag at the wrong URL entirely (e.g. the homepage instead of the specific article) — this can deindex the actual page.

  • Forgetting self-referencing canonicals — every indexable page should include a canonical tag pointing at itself, even when there are no known duplicates, as a defensive best practice.

  • Canonical tags that contradict noindex directives or redirects on the same URL, confusing crawlers about intent.

  • Using relative URLs in the canonical href — always use a full, absolute URL.

  • Paginated series (page 2, page 3) all canonicalizing to page 1, which can cause page 2+ content to never get indexed.

Warning
A canonical tag is a strong hint, not a hard directive — search engines can and sometimes do choose a different canonical URL if other signals (like backlink patterns) strongly disagree with your tag. Keep your signals consistent (redirects, internal links, and the canonical tag should all agree).
Note
Self-referencing canonicals — a page pointing its canonical tag at its own URL — are considered a best practice, not a mistake. They proactively signal your preferred URL before any duplicate ever appears.