Crawling and Indexing: Robots.txt, Sitemaps, Canonicals and Redirects
Use robots.txt, noindex, XML sitemaps, canonical tags, redirects and status codes correctly, and check indexing in Google Search Console.
Welcome back!
Step 1 of 14Learn
The site that vanished overnight
A company relaunched its website on a Tuesday. By the following week, organic traffic had dropped by 90%. The new design was lovely. The problem was one line left over from the staging site in a file called robots.txt:
Disallow: /
That line told every search engine crawler not to crawl any page on the site. Within days, rankings started collapsing. Removing the line fixed the cause, but recovery took weeks.
Technical SEO is rarely glamorous, and most of the time you don't think about it. But a few controls decide whether search engines can access, understand and index your pages at all. Getting them wrong can wipe out everything else you've done; getting them right is mostly about knowing what each tool does and not mixing them up.
The main tools are:
- robots.txt: controls crawling.
- Meta robots noindex: controls indexing.
- XML sitemaps: help discovery.
- Canonical tags: indicate the preferred version of duplicate pages.
- Redirects and status codes: tell crawlers and browsers whether a page exists, moved or is gone.
Step 2 of 14Learn
robots.txt versus noindex
robots.txt is a plain text file at the root of your domain (example.com/robots.txt). It gives crawlers instructions about which paths they may or may not crawl:
User-agent: * Disallow: /cart/ Sitemap: https://example.com/sitemap.xml
It's useful for keeping bots out of endless filter combinations, internal search results or admin areas, so they spend their time on pages that matter.
Here's the part that trips people up: robots.txt blocks crawling, not indexing. If other sites link to a blocked URL, Google can still index the URL itself, without content, and show it in results. And because the crawler can't fetch the page, it never sees any instructions on it.
To keep a page out of search results, use a noindex directive: a meta tag in the page's head, <meta name="robots" content="noindex">, or an equivalent HTTP header. The crawler must be allowed to crawl the page to see the noindex. So never block a page in robots.txt and expect its noindex tag to work.
Typical noindex candidates: thank-you pages, internal search results, login pages, thin tag archives and staging copies (which should ideally also be password-protected).
Step 3 of 14Compare
robots.txt vs. noindex
| Aspect | robots.txt Disallow | noindex meta tag |
|---|---|---|
| What it controls | Whether bots crawl a path | Whether a page appears in search results |
| Where it lives | One file at the domain root | In each page's HTML head or HTTP header |
| Can the URL still show in results? | Yes, if linked from elsewhere (without content) | No, once the page is recrawled |
| Needs the page to be crawlable? | Not applicable | Yes, or the tag is never seen |
| Good for | Saving crawl effort on low-value sections | Keeping specific pages out of the index |
Step 4 of 14Practice · True or false
Adding a page to robots.txt with Disallow is a reliable way to keep it out of Google's search results.
Step 5 of 14Learn
Sitemaps and canonical tags
An XML sitemap is a file listing the URLs you want search engines to know about, often with the date each was last modified. It helps discovery, especially for large sites, new sites with few links and pages deep in the structure. Submit it in Google Search Console and reference it in robots.txt. Include only canonical, indexable pages that return a 200 status; listing redirected, noindexed or error pages sends mixed signals. A sitemap doesn't guarantee indexing; it's a hint, not a command.
A canonical tag tells search engines which URL is the preferred version when the same or very similar content exists at multiple addresses:
<link rel="canonical" href="https://example.com/red-wool-scarf">
Typical uses:
- The same product at /scarves/red-wool-scarf and /sale/red-wool-scarf.
- URLs with tracking or sorting parameters, such as ?utm_source=newsletter or ?sort=price.
- Syndicated articles republished on partner sites.
Most pages should have a self-referencing canonical pointing to themselves. Like sitemaps, canonicals are strong hints rather than commands; Google may choose a different canonical if other signals, such as internal links and redirects, contradict yours. Keep signals consistent.
Step 6 of 14Practice · What would you do?
What would you do?
An online store's blue sweater appears at three URLs: /sweaters/blue-crew, /sale/blue-crew and /sweaters/blue-crew?color=navy&ref=email. What should the store do?
Step 7 of 14Diagram
Three URLs, one canonical
Tap a shape with to see more.
- /sweaters/blue-crew (canonical)
The version you want indexed. Every duplicate points here with rel="canonical".
- /sale/blue-crew
Same product reached through the sale category.
- /sweaters/blue-crew?color=navy
A parameter version created by a filter.
- The canonical page itself
Also carries a self-referencing canonical tag.
Step 8 of 14Learn
Status codes and redirects
Every time a browser or crawler requests a URL, the server responds with a three-digit HTTP status code. The important ones for SEO:
- 200 OK: the page exists and was delivered.
- 301 Moved Permanently: the page has a new address for good. Search engines transfer the old URL's signals to the new one. Use for changed URLs, merged pages and domain moves.
- 302 Found (temporary redirect): the move is temporary; the original URL is expected back. Using 302s for permanent moves can delay search engines in treating the new URL as the main one.
- 404 Not Found: no page at this address. Normal for genuinely deleted content with no replacement. Make the 404 page helpful, with search and links.
- 410 Gone: deleted on purpose and not coming back; a slightly stronger signal than 404.
- 500-range server errors: something broke on the server. If crawlers keep hitting these, they slow down crawling and pages can eventually drop out.
Best practices: redirect old URLs directly to their final destination, avoiding redirect chains (A→B→C) and loops. Point redirects to the most relevant equivalent page, not everything to the homepage. When migrating a site, map every important old URL to its new URL before launch.
Google Search Console is free and shows which pages are indexed and why others aren't, crawl errors, sitemap status and much more. Its URL Inspection tool shows exactly how Google sees a specific page.
Step 9 of 14Practice · Match the pairs
Match each HTTP status code to its meaning.
Tap an answer, then tap the place where it belongs (or drag it there).
- 200
- 301
- 302
- 404
- 503
Step 10 of 14Practice · Diagram
HTTP status codes at a glance
You merged two articles into one. Which code should the old article's URL return?
Tap the shape that answers the question, then press Check.
- 200 OK
The page exists and was delivered.
- 301 Permanent
Moved for good; signals pass to the new URL.
- 302 Temporary
Moved for now; the original URL is expected back.
- 404 Not Found
Nothing at this address.
- 410 Gone
Deleted on purpose, not coming back.
- 503 Unavailable
Server temporarily down, for example during maintenance.
Step 11 of 14Practice · Spot the mistake
A site moved its blog from /news/ to /blog/. Find the two setup mistakes in this redirect plan.
Step 12 of 14Note
Step 13 of 14Diagram
Launch-day indexing check
Tap a shape with to see more.
- robots.txt
No leftover Disallow: / from staging.
- noindex tags
No template still carries a noindex meta tag.
- Canonicals
They point to the live domain, not the staging address.
- Redirect map
Every important old URL 301s directly to its new home.
- Crawl and submit
Crawl the site, submit the sitemap and inspect key URLs in Search Console.
Step 14 of 14Practice · Choose one
A new site has 200 pages, but Search Console shows only 40 indexed. Which is the most sensible first step?
Lesson complete!