keepcalculator

06 Numbers and Powers

Robots.txt: Guide Crawlers, Not Hide Pages

Card No. 06·41334 · Updated · Standard formula, shown below

Yes, you use robots.txt to guide crawlers, not to hide pages. It tells search engine bots which parts of your site they may or may not crawl, but it does not prevent a page from being indexed or appearing in search results if it is linked to from elsewhere. This article explains what robots.txt really does, how it differs from noindex, and how to use it correctly.

What Robots.txt Actually Does

Robots.txt is a plain text file placed at the root of your domain (e.g., example.com/robots.txt). It follows the Robots Exclusion Protocol, a standard that allows website owners to communicate with automated web crawlers. The file contains rules that specify which user agents (crawlers) can access which paths on your site. When a crawler visits, it fetches robots.txt first, then decides whether to crawl the URLs you’ve allowed.

Importantly, robots.txt is a crawl directive, not an index directive. If you disallow a page, a compliant crawler will not fetch it, but if the page is already known (e.g., from external links), it may still be indexed based on the URL alone. Also, robots.txt is publicly visible—anyone can view it. It is not a security tool.

How Robots.txt Works: Syntax and Examples

The file uses simple syntax with two main rules: User-agent and Disallow. You can also use Allow (to override a broader disallow) and Sitemap to point to your XML sitemap. Here is a basic example:

User-agent: *
Disallow: /private/
Allow: /private/public.html
Sitemap: https://example.com/sitemap.xml

This tells all crawlers to avoid the /private/ directory but allows the specific file public.html within it. The Sitemap line is not a directive but a hint for crawlers to find your sitemap. Each rule applies to the user agent specified; you can have multiple blocks for different bots (e.g., Googlebot, Bingbot).

When to Use Robots.txt: Practical Scenarios

Use robots.txt to manage crawl budget and prevent unnecessary server load. Common use cases include:

  • Blocking search result pages, filters, or faceted navigation that create infinite URL combinations.
  • Preventing crawlers from accessing admin panels, staging sites, or internal search pages.
  • Keeping duplicate content (like print-friendly versions) out of the crawl queue.
  • Blocking resource-heavy files (e.g., large PDFs) if you don’t want them indexed.

However, do not use robots.txt to hide sensitive information. Because the file is public and crawlers may ignore it, any truly private content should be protected with authentication (e.g., password) or placed on a separate domain.

Robots.txt vs. Noindex: The Key Difference

A common misconception is that robots.txt prevents indexing. It does not. To keep a page out of search results entirely, you must use a noindex meta tag or HTTP header. The distinction is crucial:

  • Robots.txt disallow: Prevents crawling, but the page may still be indexed if it’s linked to from elsewhere (Google can index a URL without crawling it).
  • Noindex: Tells search engines to exclude the page from results, but the page must be crawled to see the tag. If you block crawling with robots.txt, the noindex tag won’t be seen, and the page might still appear.

For example, if you want to hide a thank-you page after a form submission, use noindex rather than robots.txt. If you want to save crawl budget on a huge filter combination, use robots.txt. In some cases, you might combine both, but be careful: blocking crawling can prevent the noindex from being recognized.

Common Mistakes and Pitfalls

Many site owners make errors that hurt their SEO. Here are the most frequent:

  • Blocking CSS/JS files: Modern search engines need these to render pages correctly. Blocking them can cause poor indexing.
  • Using robots.txt to hide duplicate content: This doesn’t remove duplicates from the index; use canonical tags instead.
  • Placing the file in the wrong location: It must be at the root, accessible via https://example.com/robots.txt. Subdirectory placements are ignored.
  • Forgetting to allow the sitemap: You can include a Sitemap: line, but it’s optional; many sites still get indexed without it.
  • Using wildcards incorrectly: The standard supports * and $ in some implementations, but not all crawlers interpret them the same way. Stick to simple paths for compatibility.

How to Test and Validate Your Robots.txt

Before deploying, test your file to avoid accidental blocks. You can use the robots.txt tester in Google Search Console (if you have a verified property) or third-party tools. Check that:

  • The file is served with a text/plain content type.
  • There are no syntax errors (e.g., missing colons, invalid characters).
  • Your important pages are allowed, and only the intended ones are blocked.
  • You haven’t blocked the sitemap URL accidentally.

Remember that robots.txt is cached by crawlers, so changes may take time to take effect. Also, not all crawlers obey the file; malicious bots ignore it entirely.

Alternatives to Robots.txt

Depending on your goal, other methods may be more appropriate:

  • Meta robots noindex: To exclude a page from search results while still allowing crawling.
  • X-Robots-Tag header: To set noindex, nofollow, or other directives for non-HTML files (e.g., PDFs).
  • Canonical tags: To consolidate duplicate content signals.
  • Authentication: To truly hide content from all users, not just crawlers.
  • Disallow in robots.txt: Only for crawl management, not hiding.

Frequently Asked Questions

Does robots.txt hide pages from Google?

No. It only tells Googlebot not to crawl those URLs. If the page is linked to from another site, Google may still index it without crawling, showing a snippet with no content. To remove a page from search results, use noindex or remove it entirely.

Why is my robots.txt not working?

Check the file location (must be at the domain root), ensure it’s named exactly robots.txt, and verify there are no syntax errors. Also, allow time for crawlers to re-fetch the file; it’s cached. Test with Google’s robots.txt tester to see how Googlebot interprets it.

Can I use robots.txt to block ads or tracking scripts?

You can disallow crawlers from accessing those files, but it won’t stop the scripts from running in browsers. Robots.txt only affects crawlers that choose to obey it. For actual blocking of ads, use ad-blocking software or server-side measures.

Should I block all crawlers except Google?

Generally no. Other search engines (Bing, DuckDuckGo) can bring traffic. If you have a specific reason (e.g., to reduce server load), you can block specific user agents, but be aware that some crawlers (like Yandex) may ignore the file. It’s better to allow all reputable bots.

What is the difference between disallow and allow?

Disallow tells a crawler not to request a path; Allow overrides a previous disallow for a more specific path. For example, Disallow: /folder blocks the whole folder, but Allow: /folder/one.html permits that single file. Not all crawlers support Allow, so use it cautiously.

Does robots.txt affect page speed or SEO?

Robots.txt itself doesn’t directly affect page speed, but it can influence crawl efficiency. If you block important resources, search engines may not render your pages correctly, hurting SEO. Also, if you accidentally block your CSS/JS, your pages may be considered low quality. So, test carefully.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →