Most websites publish each page at more addresses than their owners realize. A product might be reachable with and without www, over HTTP and HTTPS, with a trailing slash and without, and with tracking parameters attached. To a search engine, those are different URLs that happen to show the same content. Canonicalization is how search engines choose one of them to index and show, and redirects and canonical tags are how you influence that choice.
This lesson assumes you're comfortable with status codes and indexability from lesson 6.
Why duplicate URLs happen
Almost always by accident, through ordinary features:
- Protocol and host variants:
http://,https://,example.com,www.example.com. - Trailing slashes and case:
/shoes,/shoes/,/Shoes/. - Parameters: tracking tags (
?utm_source=newsletter), sorting (?sort=price), session ids, and filters. - Multiple paths to one item:
/shoes/trail-runner/and/sale/trail-runner/for the same product. - Print, AMP, or alternate versions of a page.
- Syndicated or copied content published on other sites.
- Index files:
/blog/and/blog/index.html.
Duplicate content isn't a penalty in itself. Google states that duplicate content on a site isn't grounds for action unless it's deceptive or manipulative. The cost is practical: signals like links are split across URLs, crawlers spend time on copies, and the search engine might show a URL you didn't want.
How search engines choose a canonical
When Google finds a set of duplicate or very similar pages, it groups them and selects one as the canonical: the representative URL to index and show. It weighs several signals, including:
- redirects (strong);
rel="canonical"annotations (strong);- whether the URL is listed in sitemaps (weaker);
- internal and external links pointing to each version;
- a preference for HTTPS over HTTP and for cleaner URLs.
All of these are hints that add up. The more of them agree, the more reliably your preferred URL is chosen. When they conflict, Google may choose a different canonical than the one you declared.
rel="canonical"
The canonical link element goes in the <head>:
<link rel="canonical" href="https://www.example.com/shoes/trail-runner/">It can also be sent as an HTTP header, which is useful for PDFs and other non-HTML files:
HTTP/1.1 200 OK
Content-Type: application/pdf
Link: <https://www.example.com/guides/sizing-chart.pdf>; rel="canonical"Rules for reliable canonicals:
- Use an absolute URL, including protocol and host.
- Include exactly one canonical per page. Multiple conflicting canonicals are likely to be ignored.
- Point to a URL that returns
200, is indexable, and is not itself redirected or canonicalized elsewhere. - Put it in the
<head>of the initial HTML. Canonicals added later by JavaScript may be processed, but static HTML is more reliable.
Self-referencing canonicals
A self-referencing canonical points to the page's own clean URL:
<!-- On https://www.example.com/shoes/trail-runner/ -->
<link rel="canonical" href="https://www.example.com/shoes/trail-runner/">It's a good default for every indexable page. When someone links to /shoes/trail-runner/?utm_source=newsletter, the same HTML is served, and the self-referencing canonical tells search engines which URL is the clean one.
301 and 302 redirects
A redirect sends visitors and crawlers from one URL to another. Choose the type by intent:
- Permanent (
301,308): the content has moved for good. Search engines transfer signals to the target and show the target in results. Use for site moves, URL changes, merged pages, and protocol or host consolidation. - Temporary (
302,307): the original will come back. Search engines tend to keep the original URL indexed. Use for short-lived situations, such as a temporary promotion or A/B testing.
308 and 307 are the same as 301 and 302 except that they require the browser to keep the request method (a POST stays a POST). For ordinary pages, 301 and 308 behave the same in search.
Server-side redirects are the clearest signal. JavaScript and meta refresh redirects can work but are slower and less reliable; use them only when you can't control the server.
Here is the same consolidation in nginx: force HTTPS and the www host with a single permanent redirect.
server {
listen 80;
listen 443 ssl;
server_name example.com;
# ssl_certificate lines omitted
return 301 https://www.example.com$request_uri;
}
server {
listen 80;
server_name www.example.com;
return 301 https://www.example.com$request_uri;
}Requests for http://example.com/a, https://example.com/a, and http://www.example.com/a each reach https://www.example.com/a in one hop.
Redirect chains and loops
A chain is a redirect that leads to another redirect: A → B → C. Googlebot follows up to 10 hops in a chain, but every hop adds latency for visitors, uses crawl effort, and adds risk if one link breaks. Collapse chains so every old URL points straight at the final one.
A loop is a chain that returns to itself: A → B → A. Browsers show an error, and crawlers give up. Loops often appear when two rules disagree, for example a CMS forcing a trailing slash while a CDN rule removes it.
# Detect loops and long chains: -L follows, --max-redirs limits hops
curl -sIL --max-redirs 10 https://www.example.com/shoes | grep -iE '^(HTTP|location)'When you change URLs again later, update old redirects too. If /a redirects to /b, and /b now moves to /c, change /a to point directly to /c.
HTTP versus HTTPS
Serve every page over HTTPS, redirect HTTP permanently, and make all internal links, canonicals, and sitemap URLs use https://. Google prefers HTTPS URLs as canonicals when both versions exist. Consider adding an HSTS header once HTTPS works everywhere, so browsers stop requesting the HTTP version at all:
Strict-Transport-Security: max-age=31536000; includeSubDomainsBe careful with includeSubDomains and the preload list: once browsers cache them, every subdomain must support HTTPS.
Trailing slash behavior
/shoes and /shoes/ are technically different URLs. Neither style is better for SEO. What matters is consistency:
- Pick one style for each type of URL.
- Redirect the other style to it with a
301. - Use the chosen style in internal links, canonicals, and sitemaps.
The root URL is a special case: https://www.example.com and https://www.example.com/ are equivalent, so there's nothing to fix there.
URL parameters
Parameters fall into two groups:
- Parameters that don't change content: tracking (
utm_*), session ids, and click ids. Keep them out of internal links. Self-referencing canonicals on the clean URL handle external links that include them. - Parameters that change content: sorting, filtering, pagination, language. Some of these create pages worth indexing (page 2 of a category), and some create near-endless combinations that aren't. Lesson 12 covers faceted navigation in depth.
Keep parameter order consistent (?color=red&size=10, never also ?size=10&color=red), and avoid putting session identifiers in URLs at all.
Common canonical implementation mistakes
- Canonicalizing every page to the homepage. This tells search engines all your pages are duplicates of the homepage; the canonical is likely ignored, and if not, your pages drop out.
- Pointing page 2, 3, and so on of a list to page 1. Paginated pages show different items; they should usually be self-canonical.
- Canonical to a URL that redirects, returns
404, or isnoindex. The signals contradict each other. - Combining
noindexwith a canonical to another page. Pick one intent. For duplicates, use the canonical alone. - Relative canonicals that resolve wrongly, such as
href="shoes/"on a nested page. - Canonicals that change between the server HTML and the rendered page because a client-side framework rewrites them.
- Blocking duplicates in robots.txt. If the crawler can't fetch a duplicate, it can't see its canonical, and links to it can't be consolidated.
Verifying your setup
- For each URL variant (protocol, host, slash, uppercase, common parameters), run
curl -sILand confirm exactly one permanent hop to the preferred URL, or a200with a canonical to it. - View the source of key templates and confirm one absolute, self-referencing canonical.
- Check that internal links and sitemap URLs use the preferred form. A crawler can report links that hit redirects.
- In Search Console, run URL Inspection on a sample. Compare User-declared canonical with Google-selected canonical.
- Watch the Page indexing report for "Duplicate, Google chose different canonical than user" and investigate those URLs first.
Key takeaways
- Duplicate URLs are normal and usually accidental. The goal is to make one version clearly preferred.
- Canonicals, redirects, sitemaps, and internal links are all signals; make them agree.
- Use permanent redirects for permanent moves, and point every old URL directly at its final destination.
- Choose one host, protocol, and trailing-slash style, and enforce it with single-hop redirects.
- Never use robots.txt to handle duplicates; it hides the signals you want read.
Exercise
Pick one important page and test 8 variants of its URL: HTTP and HTTPS, with and without www, with and without a trailing slash, an uppercase letter, and a ?utm_source=test parameter. For each, record the status codes of every hop and the final URL. Then:
- Count the variants that take more than one hop or end on a different URL.
- Write the server rule (or CMS setting) that would fix them.
- Confirm the canonical tag on the final page and the Google-selected canonical in Search Console.
Practice with RankMiso. For the exercise, RankMiso (our free extension) flags a missing, multiple, or relative canonical on the page you're on, and in Chrome, Check this site lists up to five redirect hops from a fresh request, which makes chains easy to spot. It shows the canonical you declared; the one Google selected is in URL Inspection. Free on the Chrome Web Store (opens in a new tab) and Firefox Add-ons (opens in a new tab).
References
- Google Search Central: What is URL canonicalization (opens in a new tab)
- Google Search Central: How to specify a canonical URL with rel="canonical" and other methods (opens in a new tab)
- Google Search Central: Redirects and Google Search (opens in a new tab)
- Google Search Central: URL structure best practices (opens in a new tab)
- RFC 9110: HTTP Semantics, redirection status codes (opens in a new tab)
- MDN: Strict-Transport-Security (opens in a new tab)
What's next
With one clean URL per page, the next question is how those pages connect. Internal Linking and Website Architecture shows how to structure a site of hundreds of pages so that people and crawlers can reach every important page in a few clicks.

