Skip to content

Part 1 · Getting found · Do it in RankFixer · 8 min

Control indexing: robots.txt, noindex, canonicals and sitemaps

Four tools that look similar and do different jobs. Using the wrong one is a frequent cause of missing or duplicated pages.

Each of these tools answers a different question. Ask the question first, then pick the tool.

You want toUse
Stop crawlers spending time on unimportant URLsrobots.txt
Keep a page out of search resultsnoindex, or a password
Say which of several similar URLs is the real oneA redirect or rel=canonical
Tell search engines which URLs exist and when they changedAn XML sitemap

robots.txt is for crawling

The file sits at the root of your host, for example https://example.com/robots.txt.

User-agent: *
Disallow: /cart/
Disallow: /search

Sitemap: https://example.com/sitemap.xml

This asks crawlers to skip the cart and internal search results. Google warns that robots.txt is not a way to keep a page out of its index. A blocked URL can still be indexed if other pages link to it, and then appears without a description. It is also a request: well-behaved crawlers follow it, others may not. Never use it to protect private data.

noindex is for keeping pages out

Add this to the page's <head>:

<meta name="robots" content="noindex">

For PDFs, images and video, send the same instruction as a response header. In nginx:

add_header X-Robots-Tag "noindex";

The trap: if robots.txt blocks the page, Googlebot never fetches it and never sees the noindex. Allow crawling, add noindex, and wait. Google drops the page after it recrawls it, which can take months for pages it rarely visits. Writing noindex inside robots.txt does nothing, because Google does not support it there.

Canonicals are for duplicates

The same product often lives at several addresses: with tracking parameters, with and without a trailing slash, over http and https. Google picks one canonical for the group. You can influence the choice, in this order of strength:

  1. A permanent redirect (strong). Best when the other address does not need to exist.
  2. rel="canonical" (strong). Best when both addresses must keep working.
  3. Listing the URL in your sitemap (weak).
<link rel="canonical" href="https://example.com/cakes/chocolate">

Put the tag in the head, use a full URL, and let each main page point to itself. Link to that same URL inside your site. Signals that disagree, such as a canonical pointing one way and internal links another, leave Google to decide for you. Do not use robots.txt to handle duplicates.

Sitemaps help discovery

<url>
  <loc>https://example.com/cakes/chocolate</loc>
  <lastmod>2026-11-20</lastmod>
</url>

One sitemap file holds up to 50,000 URLs or 50 MB uncompressed. Split larger sites and add a sitemap index. List only canonical URLs. Google ignores priority and changefreq. It uses lastmod when your dates prove to be accurate, so change the date only after a real update, not when the footer year changes. Submitting a sitemap is a hint, not a command.

Your turn

  1. Open your robots.txt. Can you explain every line? Remove rules nobody understands, after testing.
  2. Pick one important page and view its source. Confirm there is no accidental noindex and the canonical is the address you expect.
  3. Open your sitemap and open five URLs from it. Each should return 200 and be canonical.

Sources

Checked on 26 November 2026. Search documentation changes, so open the page if a rule matters to you.

Key takeaways

  • ✓robots.txt controls crawling. It does not reliably keep a page out of Google.
  • ✓To remove a page from results, use noindex and let Googlebot fetch the page so it can read it.
  • ✓Redirects and rel=canonical are strong duplicate signals. A sitemap entry is a weak one.
  • ✓Google ignores priority and changefreq in sitemaps, and uses lastmod only when it is accurate.

Finished this lesson?