{"canonical_url":"https://engineer.company/glossary/canonical/","content_markdown":"# Canonical URL\n\n## What it is\n\nA page that answers at several addresses can name one of them as its original,\nand the address it names is its canonical URL: the copy it asks search engines\nand other consumers to index, display and credit. The name comes from the markup\nthat carries it, a `link` element with `rel=\"canonical\"`, so the same thing also\ngoes by canonical link, canonical tag or simply rel=canonical.\n\n```html\n\u003clink rel=\"canonical\" href=\"https://example.com/guide/\" /\u003e\n```\n\nDuplicates arise more often than anyone plans for. One article can be reached\nwith and without `www`, over `http` and `https`, with a tracking parameter on\nthe end, sorted a different way, as a print view, or republished on a second\nhost. RFC 6596, published in 2012, registered the relation and set its one hard\nrule: the target must identify content that is either a duplicate of the\nreferring page or a superset of it. Within that rule the target may be the page\nitself, sit on another hostname, or use another scheme. The HTML standard\ndescribes it as the \"preferred URL for the current document\". A file that has no\nHTML head, such as a PDF, can send the same statement as an HTTP `Link` header\nwith `rel=\"canonical\"`.\n\nA canonical is a hint rather than a command. The RFC lets applications ignore a\ndesignation that is improper, and Google's documentation ranks redirects and\nrel=canonical as strong signals and inclusion in a sitemap as a weak one. Where\na page declares nothing, the search engine picks a copy itself.\n\nIt sits beside three tools that are easy to mix up with it. A permanent redirect\nremoves the duplicate for people as well as machines, which makes it the\nstronger choice whenever the extra address has no reason to stay reachable. A\n`noindex` directive keeps a page out of the index altogether, which is a\ndifferent outcome from merging it into another page. And `hreflang` ties\ntogether pages that are translations of each other; translations are\nequivalents, and none of them is a duplicate of another.\n\n## Why it matters\n\nThe decision a canonical makes is which address becomes the indexed one, and the\nonly real choice is between making it deliberately and having it made by\nsomebody else. Search engines do not punish duplicate text so much as collapse\nit: they keep one copy and fold the rest into it. The copy they keep is the one\npeople see in results, the one that links to every variant get credited to, and\nthe one a crawler returns to. Left to the engine, that copy can be the version\nwith a campaign parameter, the staging host that leaked, or a partner's\nrepublished copy instead of the original.\n\nA redirect versus a canonical is mostly a question about people. If nobody needs\nthe second address, redirect it permanently and the problem disappears for every\nclient at once; RFC 6596 itself asks authors to rule out a permanent redirect\nbefore reaching for the link. If the copy has to stay reachable, because a\ncampaign link points at it, a print layout lives there, or a second site carries\nthe article for its own audience, then the canonical is the tool, because it\nsettles the question for indexes and leaves readers alone.\n\nThe cost lies in consistency rather than in the tag. One line in the head is\ncheap. Every other place that names the page's address has to agree with it: the\n`og:url` used by link previews, the identifiers in structured data, the sitemap,\nand the site's own internal links. Two of those naming one address and the third\nnaming another is a page making two claims about itself, and a consumer may\nbelieve either. What a canonical decides is which address any standing the\ncontent earns is attached to.\n\n## What it looks like in practice\n\nThis site is a demanding case for it.\n[The same content tree publishes pages in several representations](/portfolio/built-a-multilingual-hugo-site-in-3-languages/).\nThe tree is also built for the focused subdomains.\n\nThe templates settle the duplicates with one rule: a page is its own original\nonly if it was written for the address it is served from. On the main site that\ncovers everything, so every page names itself. A focused subdomain wrote its own\nfront page and nothing else, so that page names itself while the mirrored work,\nthe shared pages and every list the generator builds point at the main site's\ncopy at the same path. The default runs in the safe direction: everything points\nhome unless it says otherwise, and a page that deserves its own identity has to\nask for it in front matter, where the asking is visible. A new kind of page\ntherefore inherits the conservative answer instead of quietly claiming to be an\noriginal.\n\nThe value is computed in one template and read everywhere it appears: by\n`rel=\"canonical\"`, by `og:url` and `twitter:url`, and by the `@id` and `url` of\nthe page's structured-data node. The sitemap and the language alternates ask the\nsame question in yes-or-no form and are emitted only when the canonical is the\npage's own address, because requesting that one address be indexed while naming\nanother as the original is a contradiction a crawler can resolve by trusting\nneither. A copy on a focused host still renders in full, and its language\nswitcher still works; what it withholds is the request to be indexed, never the\ncontent. The Markdown twin is announced from the HTML page with\n`rel=\"alternate\"` and its media type, which the HTML standard reads as the same\ndocument in another format rather than a rival page.\n\nThe main-site output check requires one absolute, self-referencing canonical on\nnormal HTML pages and checks internal page links for missing trailing slashes.\nStandalone delivered documents and the social card follow their own policies;\nfocused-host checks verify the distinction between mirrors and originals.\n\n## Where it goes wrong\n\n**Search results show an address nobody chose.** A tracking parameter, a stray\nhost or a mirror turns up as the listed URL. The page either declares no\ncanonical, or declares one while its sitemap entry, `og:url` and internal links\nname something else, so the engine weighs mixed signals and picks. Emit one\nabsolute canonical on every page, including a self-referencing one on the\noriginal, and derive the sitemap, preview and structured-data addresses from\nthat same value.\n\n**Page two of a series drops out of the index.** Every page of a paginated list\nor a split article names page one as its canonical. Page one is neither a\nduplicate nor a superset of page two, so whatever appears only on later pages\ncan be treated as duplicate and disregarded, which RFC 6596 warns about by name.\nLet each page in a series name itself, or point every page at a single view-all\npage that really contains all of it.\n\n**A duplicate blocked in robots.txt stays listed, or the original vanishes with\nit.** Blocking a duplicate's address in robots.txt stops the crawler from\nreading the page, including its canonical, and Google notes that a blocked URL\ncan still be indexed without its content. Marking duplicates `noindex` removes\nthem from search entirely instead of merging what they earned into the original.\nLeave duplicates crawlable and let a canonical or a redirect do the\nconsolidating.\n\n**The declared canonical is ignored.** The target redirects permanently\nsomewhere else, names a different canonical of its own, returns a 404, or\ncompetes with a second canonical element on the same page; script can also\nrewrite the link after the HTML arrived. Each of these makes the designation\nimproper, and the RFC lets a consumer fall back on its own judgement. Point at\nthe final address that returns 200, emit one element in the served HTML head,\nand let no script change it afterwards.\n\n## Further reading\n\n- [RFC 6596: The Canonical Link Relation](https://www.rfc-editor.org/rfc/rfc6596)\n  — the registration, the duplicate-or-superset rule and the designations to\n  avoid.\n- [HTML Standard: link type \"canonical\"](https://html.spec.whatwg.org/multipage/links.html#link-type-canonical)\n  — how HTML defines the keyword and where it may appear.\n- [RFC 8288: Web Linking](https://www.rfc-editor.org/rfc/rfc8288) — the HTTP\n  `Link` header that carries a canonical for files without an HTML head.\n- [Google Search Central: consolidate duplicate URLs](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls)\n  — how one search engine weighs redirects, canonicals and sitemaps against each\n  other.\n\n\u003chttps://engineer.company/glossary/canonical/\u003e\n","date_modified":"2026-11-12T05:34:23Z","description":"How a canonical URL tells search engines which copy of a page to index, why every signal has to name the same address, and the mistakes that split them.","formats":{"gemtext":"https://engineer.company/glossary/canonical/index.gmi","gopher":"https://engineer.company/glossary/canonical/gophermap","html":"https://engineer.company/glossary/canonical/","json":"https://engineer.company/glossary/canonical/index.json","markdown":"https://engineer.company/glossary/canonical/index.md","pdf":"https://engineer.company/glossary/canonical/index.pdf"},"kind":"page","language":"en","title":"What is a canonical URL?","url":"https://engineer.company/glossary/canonical/","version":1}