Canonical Tags in WordPress
How WordPress core handles canonicals on singular content, what it leaves out, and how to add or override them with or without a plugin.
A practical, example-driven walkthrough of adding rel=canonical correctly the first time.
The canonical tag is a <link> element that belongs in the <head> section of an HTML document, alongside other metadata like the title tag and meta description. Google only recognizes rel=canonical when it appears in the <head>; a canonical tag placed in the <body> is ignored entirely.
Each page should carry exactly one canonical tag. Google's guidance is not to declare different canonicals through different techniques on the same page - for example, one URL in the HTML head and a different URL in an HTTP header. When multiple, conflicting canonical declarations exist on one page, the widely observed behavior is that Google is likely to ignore all of them and fall back to its own selection, which means the site owner loses control over the outcome entirely.
A self-referencing canonical is a rel=canonical tag on a page that points to that same page's own preferred URL. Google recommends this as a best practice - John Mueller has described self-referencing canonicals as "not critical" in the sense that a site will not break without them, but they remove ambiguity whenever a page happens to be reachable through variant URLs, such as with a tracking parameter or a different trailing slash.
To add one, open the page's HTML source (or its template, if the page is generated by a CMS) and insert a link element inside the head, using the exact absolute URL of the page as the preferred version is meant to appear:
<head>
<title>Example Page Title</title>
<link rel="canonical" href="https://www.example.com/page/" />
</head>The URL inside the href attribute must exactly match the preferred, indexable version of the page - same protocol, same host, same case, same trailing-slash convention as the version a site wants indexed.
Files that have no HTML head at all - PDFs are the most common example - can still carry a canonical declaration. Since 2011, Google has supported specifying rel=canonical through an HTTP Link header, sent as part of the server's response rather than embedded in the document itself.
A server response for a PDF file might include a header like this:
Link: <https://www.example.com/downloads/file.pdf>; rel="canonical"This tells crawlers which URL is the preferred, canonical location of that file, exactly the same way an HTML rel=canonical tag would for a web page. This approach is configured at the server or application level - in Apache, Nginx, or the application code generating the response - rather than in a document a browser renders.
A canonical tag's href value can technically be written as either an absolute URL (https://www.example.com/page/) or a relative one (/page/), and both are technically supported. Google's guidance, however, is to use absolute URLs: "Use absolute paths rather than relative paths with the rel=canonical link element."
The risk with relative canonicals is that they resolve against whatever host and protocol the page happens to be crawled on at that moment. Google specifically warns that relative paths "can cause problems in the long run" - for example, if a staging or testing subdomain is unintentionally crawled, a relative canonical on that staging copy will resolve to the staging host rather than the intended production URL, which can create exactly the kind of conflicting signal that gets a canonical ignored. Writing the full absolute URL removes that ambiguity regardless of where or how the page is crawled.
A few checks confirm a canonical tag is actually in place and being read correctly:
Manually editing HTML head elements works for a handful of pages, but most sites need canonical tags applied consistently across hundreds or thousands of URLs. There are two general approaches:
Whichever approach is used, the priority at scale is the same one that matters for a single page: keep every signal consistent. The canonical tag, the sitemap, and internal links across the entire site should agree on the same preferred URL form - same protocol, same host, same trailing-slash convention - because a mismatch between rel=canonical and any of those other signals is exactly what leads Google to override the declared canonical.
No. Google only recognizes rel=canonical tags placed in the HTML head. A canonical tag placed in the body is ignored entirely.
A page should have exactly one. Google's guidance is not to declare different canonicals through different techniques on the same page, and the widely observed behavior when a page has multiple, conflicting canonical declarations is that Google ignores all of them and selects its own canonical instead.
PDFs and other non-HTML files do not have an HTML head, so the canonical is declared through an HTTP Link header sent by the server instead, in the form: Link: <https://www.example.com/downloads/file.pdf>; rel="canonical". Google has supported this since 2011.
Google recommends absolute URLs. Relative canonical URLs resolve against whatever host and protocol the page is crawled on, which Google warns can cause problems if a staging or alternate host is ever crawled unintentionally.
View the page's raw HTML source to confirm the tag is present and correct, then check the same URL in Google Search Console's URL Inspection tool to see whether Google's selected canonical matches the one declared.
How WordPress core handles canonicals on singular content, what it leaves out, and how to add or override them with or without a plugin.
A canonical tag that points a page at its own URL, the recommended baseline that removes ambiguity from parameter and variant URLs.
Setting canonicals in Next.js with the App Router Metadata API, the Pages Router, next-seo, and the metadataBase gotcha to avoid.