Robots.txt

■ QUICK DEFINITIONRobots.txt is a plain text file at the root of a website that tells search engine crawlers which URLs they may or may not request. It controls crawling, not indexing.
By Mandeep Singh ChahalLast updated:
01 · Overview

What is robots.txt?

Google's robots.txt guide says the file is "used mainly to avoid overloading your site with requests." It also warns that robots.txt "is not a mechanism for keeping a web page out of Google." A blocked page can still be indexed if other sites link to it, and its URL can still appear in results.

To keep a page out of search, use a noindex rule or password protection. The file lives at yourdomain.com/robots.txt and uses simple User-agent, Disallow, Allow and Sitemap lines.

02 · Impact

Why robots.txt matters

  • Protects server load: Stops crawlers from hammering search results pages, filters or scripts.
  • Saves crawling for real pages: On big sites it keeps Googlebot on the URLs that matter. See crawl budget.
  • Points to your sitemap: A Sitemap line helps crawlers find your XML sitemap.
03 · Playbook

How to write a robots.txt file

  1. Find the current fileOpen yourdomain.com/robots.txt. If it is missing, crawlers assume everything is allowed.
  2. List what to blockInternal search results, cart and checkout URLs and endless filter parameters are common choices.
  3. Write the rulesStart with User-agent: * then add Disallow lines for each path. Add a Sitemap line with the full URL.
  4. Test before publishingUse the robots.txt report in Search Console to check Google can fetch and read the file.
  5. Decide on AI crawlersYou can allow or block bots such as GPTBot by their user agent. Blocking them may keep you out of those tools.
04 · Example

An example of robots.txt

Picture a WordPress site where a developer left "Disallow: /" from the staging server. The live site stops getting crawled, and new posts never appear in Google. Removing that one line and requesting a recrawl fixes it.
05 · Pitfalls

Common robots.txt mistakes

  • Blocking the whole site: "Disallow: /" left over from staging is the most damaging single line in SEO.
  • Using robots.txt to hide pages: Blocked pages can still be indexed from outside links. Use noindex instead.
  • Blocking pages that have noindex: Google has to crawl a page to see noindex. If robots.txt blocks it, the rule is never seen.
  • Blocking CSS and JavaScript: Google needs those files to render the page properly.
06 · Expert tip

Expert tip from Mandeep Singh Chahal

Mandeep Singh Chahal
Digital marketing expert

Check robots.txt on the day any new site or redesign goes live. I have seen more traffic lost to a forgotten staging rule than to any algorithm update.

07 · FAQs

Frequently asked questions

Does robots.txt stop a page from being indexed?
No. Google says a disallowed page can still be indexed if other sites link to it. Use noindex to keep it out of results.
Where is the robots.txt file?
It must sit at the root of the host, for example https://example.com/robots.txt.
Can I put noindex in robots.txt?
No. Google does not support noindex rules inside robots.txt.
Do all bots obey robots.txt?
Major search engines do. Bad bots and scrapers often ignore it, so it is not a security tool.
Should I block AI crawlers in robots.txt?
It depends on your goals. Blocking AI crawlers may protect content but can reduce how often AI tools mention or cite you.
What happens if I have no robots.txt file?
Crawlers treat the site as fully open to crawling. That is fine for most small sites.
Get a FREE Audit WhatsApp