07887 423199me@richieaubin.com

Set a canonical in HTML or an HTTP header

Use a canonical when several addresses serve the same or very similar content and you want search engines to prefer one of them. Check that the preferred page is a suitable equivalent before changing a tag.

Canonical URL implementation example
Example image · CC0 1.0 licence

Choose a way to do this check

Canonical checker on this site

  1. Paste the original HTML and enter the exact page URL.
  2. Review duplicate declarations and the resolved target. Check HTTP Link headers separately.

Screaming Frog canonical export

  1. Open the Canonicals view, export affected URLs and compare crawl targets.
  2. Confirm that targets are accessible, equivalent pages and that linked URLs match your plan.

Search Console URL Inspection

  1. Compare the nominated canonical with Google’s selected URL where shown.
  2. If they differ, review redirects, sitemap entries, inlinks and page equivalence before changing the tag.

Follow the illustrated walkthroughs for Screaming Frog’s Canonicals tab.

1. Compare the duplicate and the preferred address

Start with two real URLs. Open both and compare what a reader can do on each. A campaign parameter may leave the page unchanged. A product variant with its own meaningful content may need its own URL. Before consolidating, check that the chosen URL returns 200, is crawlable, is indexable and matches the intent of the source.

Pick one absolute canonical URL with the correct scheme, host and trailing slash. If your CMS allows editors to override canonicals, decide when an override is justified and who reviews it. Record one control page that should keep its existing canonical.

2. Add the HTML tag

Place the link element in a valid HTML head in the original response. Use one consistent declaration. If your front end also writes a canonical after rendering, verify that it stays the same.

Duplicate or preferred HTML page · inside head
<link rel="canonical"
      href="https://www.example.com/guides/sizing/">

On the preferred HTML page, a self-referencing canonical can make your intent clear. Do not point unrelated pages at the same URL to try to consolidate traffic.

If an equivalent PDF should consolidate to the HTML guide, you can send the canonical in its HTTP response. Confirm that your proxy or CDN preserves it. Choose the delivery method that fits the resource, and avoid sending conflicting header and HTML signals where both are used.

Response header for the equivalent PDF
Link: <https://www.example.com/guides/sizing/>; rel="canonical"

Do not add this example verbatim to a server configuration. Configure the server, CDN or application to emit the header for the intended response while leaving unrelated files alone. Check that the PDF is truly equivalent to the HTML guide.

For Apache 2.4 with mod_headers, the following example applies the header to a named PDF. Use it in the directory for that file. Check for an existing Link header first. A replacement header can remove other active Link relationships, so merge deliberately when the application already uses that header.

Apache · .htaccess in the PDF directory
<Files "sizing.pdf">
    Header set Link "<https://www.example.com/guides/sizing/>; rel=\"canonical\""
</Files>

Fetch the duplicate and preferred URLs. Review the HTML as a parsed document where possible because a simple text match will not detect invalid tag placement. Check that your internal links, sitemaps and redirect rules support the same preferred URL. If the preferred URL redirects, update the canonical to point directly to the correct destination.

Terminal · check the PDF response headers
curl -sS -D - -o /dev/null \
  https://www.example.com/guides/sizing.pdf \
  | grep -Ei '^(HTTP/|content-type:|link:)'

Google treats a canonical declaration as a signal. Check the user-declared and Google-selected canonical in URL Inspection as separate fields. If they differ, review equivalence and conflicting signals rather than repeatedly replacing a valid tag. Reverse the configuration change if the wrong pages are affected, then confirm the corrected output before checking the indexed state again.

Technical references

Frequently asked questions

Should paginated pages all canonicalise to page one?

Set the preferred address for each distinct page in the series. A page with different items is not equivalent to page one.

Is a canonical a redirect?

No. People can usually still visit the duplicate. A redirect takes the request to a new address.

Can I declare a canonical for a PDF?

Yes. An HTTP Link header can declare it on a non-HTML response.

What if Google selects a different URL?

Check content equivalence, sitemaps, links and redirects. The declaration is a preference, and Google makes the selection.

Written by Richie Aubin

Published