Sub topic 8
Reading canonical, redirect, noindex and robots signals
This chapter assumes you can read an HTTP status code, find a <link> element in a page head, and filter a crawl export with pandas. The earlier chapters grouped duplicates by hash and shingle similarity. This chapter covers what each page already tells search engines about itself, so you can decide whether a duplicate group needs a fix or is already handled.
Four signals, four different jobs
The four signals are often lumped together as "duplicate handling", but each does something different. Confusing them causes most wrong fixes.
| Signal | Where it lives | What it controls | Strength |
|---|---|---|---|
| Redirect (301, 302, 307, 308) | HTTP response | Which URL the visitor and crawler end up on | Strong |
| Canonical | `<link>` in the head, or an HTTP `Link` header | Which URL you prefer among similar pages | Hint |
| noindex | Meta robots tag or `X-Robots-Tag` header | Whether this page may appear in search results | Directive, once seen |
| robots.txt | `/robots.txt` on the host | Whether a crawler may fetch the URL | Controls crawling only |
A search engine follows a redirect, treats a canonical as a suggestion and obeys noindex only after it fetches the page. robots.txt stops the fetch, so it can hide the other signals.
Canonical
A canonical link element names the URL you prefer among near-identical pages:
<link rel="canonical" href="https://example.com/shoes/">Search engines treat this as a hint. They may ignore it if the pages differ materially, or if other signals such as redirects, internal links and sitemap entries point to a different URL. When you audit canonicals in a crawl, check the following.
- Self-referencing canonical. A page that names itself is the normal healthy state. A duplicate group where every member names itself has no consolidation signal at all.
- Canonical to another URL. This is the consolidation case. Check the target.
- Target status. A canonical pointing at a redirect, a 404 or a blocked URL is a broken instruction.
- Target indexability. A canonical pointing at a noindex page sends mixed signals.
- Chains. If A names B and B names C, the engine may not follow it through. Each page should name the final preferred URL directly.
- Multiple canonicals. Two different canonical declarations on one page, for example one in the HTML and one in a header, can cause both to be ignored.
- Canonical outside the head. A canonical placed in the body is not valid and is generally ignored. Plugins and templates sometimes inject one there.
- Relative or mismatched URLs. A relative
href, or one with a different protocol or host than the final URL, can create a new variant. Compare canonicals after the same normalization you applied to page URLs.
Redirects
Redirects are the strongest consolidation signal because the visitor never sees the duplicate. Read the status code for intent.
- 301 and 308 mean the move is permanent.
- 302 and 307 mean temporary. A temporary redirect left in place for months is usually a mistake, because it tells engines the old URL may return.
In a crawl, look for these problems:
- Chains. A to B to C wastes crawl requests and delays consolidation. Point A straight at C.
- Loops. A to B to A never resolves. Crawlers report these as errors.
- Redirect to a non-200. The destination should return 200.
- Internal links to redirecting URLs. The redirect works, but the site still advertises the old URL. Update the links.
- Canonical or sitemap entries pointing at redirecting URLs. These conflict with the redirect.
noindex
noindex asks that a page stay out of search results. It appears as <meta name="robots" content="noindex"> in the head or as an X-Robots-Tag: noindex response header. The header form is the only option for non-HTML files such as PDFs.
For duplicates, noindex is a different tool from a canonical. A canonical says "this page is a version of that page, so combine them." noindex says "drop this page." Dropping a page does not pass its signals to another URL, and a page that is both noindex and canonical to another URL gives contradictory instructions. Treat that combination as a finding to resolve.
Always read both the meta tag and the header. Crawl exports often have separate columns for them, and a noindex in only one still applies.
robots.txt and the visibility problem
robots.txt controls fetching. It does not remove a URL from an index. A blocked URL can still be indexed, usually with no description, if other pages link to it.
This matters for diagnosis because a blocked page's other signals are invisible:
- A crawler that obeys robots.txt never fetches the page, so it never sees a noindex tag on it.
- It never sees the canonical on it.
- It never sees a redirect from it.
So if you want a page removed with noindex, do not also block it in robots.txt. If you block a parameter space to save crawl budget, accept that you can no longer consolidate it with canonicals. In your export these rows show a blocked flag, an empty status or no body text, and they will not appear in the hash groups from the earlier chapters. An absent duplicate in your analysis may be a blocked one.
Which signal wins when they disagree
Signals combine, and the table below shows how to read common combinations.
| Combination | Reading |
|---|---|
| 200, self canonical | Page asks to be indexed as itself |
| 200, canonical to another 200 page | Consolidation attempt. Check that content really matches |
| 200, canonical to a redirect or 404 | Broken instruction. Fix the target |
| 200, noindex, self canonical | Page is excluded on purpose. Confirm intent |
| 200, noindex, canonical to another URL | Mixed message. Choose one |
| 3xx | Handled by redirect. Check chain length and destination |
| Blocked by robots.txt | Other signals unreadable. Review the rule |
A decision order for reading a row
Evaluate signals in the order a crawler meets them. The following diagram shows that order.
Classifying every row in a crawl
The script below applies this order to a small export and then audits canonical targets against the crawl itself. The canonical column holds the declared canonical URL, and the two robots columns hold the meta and header values.
import pandas as pd
df = pd.DataFrame(
[
("https://example.com/shoes/", 200, "https://example.com/shoes/", "", "", False),
("https://example.com/shoes?color=red", 200, "https://example.com/shoes/", "", "", False),
("https://example.com/old-shoes", 301, "", "", "", False),
("https://example.com/sale", 200, "https://example.com/old-shoes", "", "", False),
("https://example.com/search?q=boots", 200, "", "noindex, follow", "", False),
("https://example.com/cart", 0, "", "", "", True),
],
columns=["url", "status", "canonical", "meta_robots", "x_robots_tag", "robots_blocked"],
)
def classify(row):
if row["robots_blocked"]:
return "blocked: signals unreadable"
if 300 <= row["status"] < 400:
return "redirect"
if row["status"] >= 400:
return "error"
directives = f"{row['meta_robots']} {row['x_robots_tag']}".lower()
if "noindex" in directives:
return "noindex"
if row["canonical"] == "":
return "no canonical"
if row["canonical"] == row["url"]:
return "self-canonical"
return "canonical elsewhere"
df["state"] = df.apply(classify, axis=1)
# Look up the status of each canonical target within the same crawl.
status_by_url = df.set_index("url")["status"]
df["canon_status"] = df["canonical"].map(status_by_url)
# A target missing from the crawl gives NaN, which is also worth reviewing.
bad_target = (df["state"] == "canonical elsewhere") & (df["canon_status"] != 200)
print(df[["url", "state", "canon_status"]])
print(df[bad_target]["url"].tolist())The final line prints only https://example.com/sale, because its canonical points at a URL that returns 301. The color-variant page passes because its target returns 200.
Extend this by also joining the target's state. A canonical whose target is noindex or blocked is the same kind of broken instruction.
Signals inside a duplicate group
Once you have a state column, combine it with the hash groups from earlier chapters. For each group, count how many members fall into each state.
- All members self-canonical. Nothing consolidates the group. This is the most common finding and needs a fix.
- One self-canonical, the rest canonical to it. The group is handled. Verify the canonical targets return 200 and match.
- Members split across different canonical targets. The site disagrees with itself. Pick one preferred URL.
- Members redirecting to one 200 page. Handled. Check for chains.
- Mix of noindex and indexable members. Check whether the noindex ones are intentional.
Reading the existing state first prevents you from recommending a canonical for a group that already redirects, or a redirect for a group that is correctly noindexed on purpose.
Exercise
A crawl shows 400 parameter URLs, each returning 200 with a canonical pointing at the clean category URL. The same 400 URLs are also blocked by a robots.txt rule added last year. Does the canonical consolidate them, and what would you check?
Show answer
Probably not as intended. A crawler that obeys robots.txt never fetches the blocked URLs, so it never reads their canonical tags, and your crawler can only see them if it ignored robots.txt. The URLs may still be indexed from links alone. Check whether the engine has indexed any of them. If consolidation is wanted, remove the robots.txt rule so the canonical can be read, and keep the canonicals pointing at a 200 clean URL. If you prefer to block crawling, accept that the canonical will not be read.