Sub topic 8
Reading canonical, redirect, noindex and robots signals
This chapter assumes you can read a crawl export, know HTTP status codes, and can filter rows in pandas or a spreadsheet. Once you have a group of duplicate URLs, check how the site already handles it. The fix you choose later depends on that.
The four signals
Each signal tells search engines something different, and they do not all mean the same thing.
| Signal | Where it lives | What it says | Strength |
|---|---|---|---|
| Redirect (301, 302) | HTTP response | This URL has moved. Go to the target. | Strong. The old URL is not shown. |
| Canonical | `<link rel="canonical">` or HTTP header | Prefer this URL among similar pages. | A hint that engines may ignore. |
| Noindex | Meta robots tag or `X-Robots-Tag` header | Do not keep this page in the index. | A directive, but only if the page can be fetched. |
| robots.txt | `/robots.txt` file | Do not crawl these paths. | Controls crawling, not indexing. |
A canonical looks like this:
<link rel="canonical" href="https://example.com/shoes/">Reading them in a crawl
Most crawlers record these as columns. A typical export has url, status, redirect_target, canonical, meta_robots, x_robots_tag and robots_txt_blocked. For each duplicate group, classify every URL with a function like this:
import pandas as pd
def classify(row):
if row["status"] in (301, 302, 307, 308):
return "redirects"
if row["robots_txt_blocked"]:
return "blocked_by_robots"
robots = f'{row["meta_robots"]} {row["x_robots_tag"]}'.lower()
if "noindex" in robots:
return "noindex"
canonical = row["canonical"]
if pd.isna(canonical):
return "no_canonical"
if canonical == row["url"]:
return "self_canonical"
return "canonical_elsewhere"
df = pd.read_csv("crawl.csv")
df["handling"] = df.apply(classify, axis=1)
print(df["handling"].value_counts())Groups where every variant is redirects, noindex or canonical_elsewhere pointing to one target are already handled. Groups full of self_canonical or no_canonical rows are the ones to investigate.
Conflicts to look for
Signals can contradict each other. These are the common cases:
- Canonical points to a redirect or error. The target should return 200. Check the target's
status. - Canonical chain. A points to B, and B points to C. Engines may stop following the chain, so each URL should point straight to the final target.
- Noindex plus canonical. The two signals send different messages: noindex says to drop the page, and canonical says to merge it into another. Pick one.
- Blocked by robots.txt but marked noindex or canonical. The crawler cannot fetch the page, so it never sees the tag. The URL can still be indexed from links alone.
- Canonical disagrees with links and sitemaps. If internal links and the sitemap favor URL A but the canonical says B, the signals are mixed.
A decision flow
Check the canonical target
For each canonical_elsewhere row, confirm the target is healthy:
status_by_url = df.set_index("url")["status"]
elsewhere = df[df["handling"] == "canonical_elsewhere"].copy()
elsewhere["target_status"] = elsewhere["canonical"].map(status_by_url)
bad = elsewhere[elsewhere["target_status"] != 200]
print(bad[["url", "canonical", "target_status"]])A missing target_status (NaN) means the target was not crawled. Treat that as something to check, not as a pass.
Exercise
A crawl shows a duplicate URL that is blocked by robots.txt and also carries a noindex tag. Why might it stay in search results, and what would you change?
Show answer
The crawler cannot fetch a blocked page, so it never reads the noindex tag. The URL can still be indexed from links pointing to it. Remove the robots.txt block so the page can be crawled, keep the noindex, and let the page drop out. Once it is gone, you can decide whether to block it again.