Skip to the content
All posts

Canonicals3 min read

Five ways a deploy breaks canonical tags

A canonical tag is one line that names the page to index. Five common ways a release points it at the wrong place, and what each one costs.

The same page is often reachable at several addresses: with and without a trailing slash, with tracking parameters, under a preview host. The canonical tag is how a page says which of them is the real one.

A canonical tag
<link rel="canonical" href="https://example.com/pricing">

It is one line, usually written once in a layout and never looked at again. That is why a release can change it on every page at the same time.

1. It points to the wrong host

The address is normally built from a base URL in the environment. If production is built with the preview's value, every page names a preview or staging host as its home. Search engines may index that host instead and drop yours.

2. Every page names the same page

A layout that hard-codes the canonical, or reads it from the site's settings instead of the current route, tells search engines that all pages are copies of the home page. The pages still load. They are only no longer candidates for search.

3. There are two of them

A plugin adds a canonical, and so does the layout. Or the tag says one thing and a Link response header says another. When several canonicals disagree, search engines ignore all of them and choose for themselves.

4. It points to a dead end

After a URL change, old canonicals can point to an address that now redirects, returns 404 or carries a noindex. The page asks to be replaced by something that cannot be indexed, and the two signals contradict each other.

5. A script sets or changes it

If the server's HTML has one canonical and the page's scripts replace it with another, a crawler can meet either one. Crawlers that do not run scripts only ever see the first.

Checking after a release

Reading one page's source is not enough, because the failures above are about patterns across pages. A useful check does four things:

  • collects the canonical of every page, from the tag and from the headers;
  • flags any that name another host, or that are not a valid address;
  • follows each one, to see that it loads and is not noindex;
  • compares with the last crawl, so a canonical that changed stands out.

With Ranky

Ranky has a check for each of these: a missing canonical, more than one, an invalid address, another host, a target that does not load and a target that is noindex. When scripts change what the server sent, that is reported too. Each issue shows the value before and after, and the deploy that changed it.

See the canonical checks in Checks.

Catch the next bad deploy before search engines do

Start with one site, free. Every check, weekly scans, no card needed.