Skip to content
Free AI visibility check: does your brand show up in ChatGPT and Gemini answers?Apply →

What Is Robots.txt? The File That Directs Search Engine Crawlers

Robots.txt is a simple text file in your site's root directory that tells search engine bots which sections to crawl and which to leave alone. It works with the User-agent, Disallow, Allow and Sitemap directives, manages crawl budget and protects server resources. However, blocking crawling does not block indexing; that takes a noindex tag.

Last updated: View as Markdown

Selin Öztürk

A robots.txt file is a simple text file websites use to guide search engine crawlers on which pages to crawl and index. It is vital for controlling how search engines interact with your site. Configured correctly, it can keep unnecessary or sensitive content on your site from being indexed by search engines and help your crawl budget be used more efficiently.

How Does It Work?

  • Crawlers: when web crawlers (such as Googlebot) visit a website, the first place they look is the robots.txt file. By reading it, they determine which pages or directories to avoid and which to crawl.
  • Location: the robots.txt file must be in the website's root directory (e.g. www.example.com/robots.txt). If it's in the wrong place, search engines can't find it and ignore your directives.

Core Directives: What Is Robots.txt? The Art of Communicating With Search Engines

Imagine your website as a large building. It has public exhibition halls, libraries and a cafeteria open to everyone. But it also has private offices, an executive floor, archive rooms and sections under renovation that aren't open to visitors yet. So how do you tell the visitors who come to your building (especially search engine bots like Google's) where they can and can't go?

That is exactly what a robots.txt file is. It is a simple text file in your site's root directory that tells search engine bots, "Welcome, here are our rules." Using the Robots Exclusion Protocol (REP), it contains directives specifying which parts of your site bots may or may not crawl.

This is one of the most basic and most critical steps in technical SEO. The first step to healthy communication with search engines is giving them clear, unambiguous directives.

Why Does the Robots.txt File Matter So Much?

There are several strategic reasons why such a tiny text file matters so much:

  • Managing crawl budget: search engines allocate a certain amount of resources and time to crawling your site. This is called the "crawl budget". If your site has thousands of unimportant pages (for example, internal search result pages, filtered product pages, admin login panels), bots may waste their valuable time crawling them. By excluding such pages from crawling with robots.txt, you make sure bots focus their energy on your truly important pages, products and blog posts.
  • Protecting server resources: heavy bot traffic can overload the server, especially on large sites or sites with weak servers, and slow the site down. robots.txt can help protect your server by controlling how fast bots crawl the site (with the Crawl-delay directive for some bots).
  • Hiding private and unimportant pages: it keeps test pages that aren't ready to go live, admin panels and private directories you don't want users to see away from search engines.
  • Pointing to the sitemap: by stating where your sitemap is directly in the robots.txt file, you make it easier for your important pages to be discovered.

Robots.txt Syntax: How to Talk to Bots

The robots.txt file works with specific directives. The most commonly used are:

  • User-agent: names the bot you're addressing. Every bot has its own identity (for example, Googlebot for Google, Bingbot for Bing). If you want to apply the same rule to all bots, you use the * (asterisk) character.
  • Disallow: the "No Entry" directive. It specifies the URLs or directories you don't want bots to crawl.
  • Allow: the "Entry Permitted" directive. It is usually used to grant access to a specific file or subfolder inside a directory blocked with Disallow.
  • Sitemap: specifies the full URL of your site's XML sitemap file.

Practical examples:

Example 1: Blocking a specific folder for all bots

User-agent: * Disallow: /admin-panel/

This directive stops all search engine bots from crawling the www.sitename.com/admin-panel/ directory and everything in it.

Example 2: Blocking a specific file for Googlebot only

User-agent: Googlebot Disallow: /secret-campaign.html

This directive stops only Googlebot from crawling the secret-campaign.html file. Other bots can crawl this page.

Example 3: Blocking a folder but allowing one file inside it

User-agent: * Disallow: /media/ Allow: /media/logo.png

This directive stops all bots from crawling the /media/ folder but allows them to access the logo.png file inside it.

Example 4: Specifying the sitemap

User-agent: * Disallow: /cart/ Disallow: /my-account/ Sitemap: https://www.sitename.com/sitemap.xml

This directive tells all bots not to crawl the /cart/ and /my-account/ directories and shows them where the site's sitemap is.

The Most Critical Distinction: Blocking With Robots.txt vs. Hiding With noindex

This is the most commonly confused topic, and it can lead to the most dangerous mistakes.

  • Blocking a page in robots.txt with a Disallow directive tells Google, "Don't crawl this page." It does not mean the page will definitely be removed from search results. If there are links to that blocked page from other sites or elsewhere on your site, Google can index it without crawling it and show only its URL in search results.
  • Adding a <meta name="robots" content="noindex"> tag to the <head> section of an HTML page, on the other hand, tells Google, "Don't index this page." This is the most reliable and correct way to keep a page out of search results.

Strategic use: if you definitely don't want a page to appear in search results, here's what to do:

  • Make sure the page is not blocked by robots.txt (that is, let Google crawl the page).
  • Add the noindex tag to the page's HTML. Googlebot will crawl the page, see the noindex tag and drop it from the index. This is the most important part of managing your site's index.

How to Create and Test a Robots.txt File

Creating it:

  • Open a simple text editor such as Notepad (Windows) or TextEdit (Mac).
  • Write your directives following the syntax above.
  • Save the file as robots.txt (all lowercase).
  • Upload the file to your website's root directory via FTP or cPanel. Your file should be accessible at https://www.sitename.com/robots.txt.

Testing it: the most reliable way is to use the "Robots.txt Tester" in Google Search Console. It shows your file's contents, flags any syntax errors and lets you test whether a specific URL is blocked by your file.

Conclusion: A Cornerstone of SEO

Although the robots.txt file looks like a simple text file, it forms the foundation of a website's relationship with search engines. Configured correctly, it optimizes your crawl budget, protects your server and steers search engines' energy toward the right pages, improving your overall SEO performance. This small but powerful file is key to your site's technical health and to being understood correctly by search engines.

Last updated:

Help with this topic

SEO

As an SEO agency, let's build your brand a permanent, profitable sales channel that grows every month.

24+

AI visibility

Sample data

Read the Modaltrans case
Clutch5.08 reviews (5.0 out of 5) (opens in a new tab)

Let’s turn the terms into a plan.

We review your measurement and goals together and set the priorities.