A robots.txt file is a plain text file placed in the root directory of a website that tells search engine crawlers which URLs they may or may not crawl. It follows a standard called the Robots Exclusion Protocol, and it works as a set of polite instructions rather than a lock. Well-behaved bots such as Googlebot read it before crawling, while it does not by itself stop a page from appearing in search results. If you are deciding whether your site needs one, the short answer is that most sites benefit from having one, even a very simple one. This guide covers what the file does, how to write it, how it behaves on real servers and large sites, and how to avoid the mistakes that cause genuine ranking problems.
Table of contents13 sections
What Is Robots.txt File?
A robots.txt file (sometimes written robots txt, robots text, or robot.txt) is a small text file that sits at the top level of your domain, for example `example.com/robots.txt`. It speaks to web crawlers, the automated programs that search engines use to discover pages. Each rule names a crawler and tells it which paths to stay out of or which paths are open.
Think of it as a note on the front door of a building. It does not physically stop anyone, but legitimate visitors read it and follow it. Robots.txt is also an important part of technical SEO, as it helps website owners manage how search engines crawl their websites.
What Is the Purpose of Robots.txt?
The main purpose is to manage crawler access. You use it to keep bots away from areas that waste crawl activity, such as internal search results, cart pages, or admin folders. You can also point crawlers to your XML sitemap so they find your important pages faster.
It is also useful for controlling server load. If aggressive bots hit your site constantly, a few well-placed rules can reduce unnecessary requests. However, robots.txt is a crawling tool, not a privacy tool, and that distinction matters throughout this guide.
What Is the Robots Exclusion Protocol (REP)?
The Robots Exclusion Protocol is the informal standard behind the file. It was proposed in the 1990s and has since been formalized as an internet standard (RFC 9309). The protocol defines how the file is named, where it lives, and how directives such as user-agent, allow, and disallow should be interpreted. Because it is voluntary, compliance depends on the crawler. Major search engines follow it, while malicious bots usually ignore it.
Where Is the Robots.txt File Located?
The file must sit in the root directory of the host, such as `https://www.example.com/robots.txt`. A file placed in a subfolder, like `/blog/robots.txt`, will not be read. The file name must also be lowercase and exactly `robots.txt`.
The scope of the file is narrower than many people expect. It applies only to the exact combination of protocol, host, and port where it is served. That means `http://example.com`, `https://example.com`, and `https://www.example.com` are treated as three separate locations, and each can have its own file. A file on a non-standard port, such as `https://example.com:8443`, covers only that port. In practice, most sites redirect every version to a single preferred address, so the file on that version is the one that matters, but it is worth checking that the others do not serve conflicting rules.
How Does Robots.txt Work?
When a crawler arrives at your site, it first requests the robots.txt file. It reads the rules that apply to its own name, then decides which URLs it is allowed to request. If the file says a path is off limits, a compliant crawler skips it.
How Search Engine Crawlers Read and Follow Robots.txt Rules
Crawlers parse the file looking for the group of rules that matches their user agent. Google caches the file and generally refreshes it within about 24 hours, so a change is not always picked up instantly. If a crawler finds a specific group for its name, it follows only that group and ignores the generic `*` group. This surprises many site owners, so test any file that contains several groups.
Parsing itself is forgiving but not magical. Google accepts UTF-8 text and ignores a byte order mark (BOM) at the start of the file, and it handles both LF and CRLF line endings. Blank lines are fine and simply separate groups visually. Lines it cannot understand, such as a misspelled directive or a rule with no colon, are skipped rather than causing the whole file to fail. That sounds safe, but it also means a typo like `Dissallow:` quietly does nothing, so the rule you thought was protecting a folder is not working at all. If the same user agent appears in more than one group, Google merges those groups into one, though other crawlers may not be so tolerant, which is a good reason to keep each user agent in a single group.
Caching matters on modern infrastructure too. If your site sits behind a CDN or a reverse proxy such as Cloudflare, the robots.txt response may be cached at the edge. A crawler can then receive an older version of the file even after you have uploaded a new one. Some security and CDN services can also serve or modify the file themselves. For that reason, always check what is actually delivered to crawlers, not just what sits on your origin server.
What Happens When a Website Has No Robots.txt File?
If the file is missing and the server returns a 404, crawlers assume everything may be crawled. A missing robots.txt is not a penalty. Still, it means you lose the chance to guide bots, and your server logs will fill with 404 requests for the file. A plain allow-all file with a sitemap line is a tidy alternative.
Does Robots.txt Prevent Google from Indexing a Page?
No, and this is the most common misunderstanding. Blocking a URL stops Google from crawling it, but if other pages link to it, Google can still index the bare URL without its content. You will then see a result with no description. To keep a page out of search results, use a noindex meta tag or an X-Robots-Tag header, and make sure the page is crawlable so Google can see that instruction.
Why Is Robots.txt Important for SEO?
Robots.txt matters for SEO because it shapes how search engines spend their time on your site. It will not make a weak page rank, but it can stop crawlers from wandering into areas that add nothing.
How Robots.txt Helps Manage Crawl Budget and Server Resources
Crawl budget is the number of URLs a search engine is willing and able to crawl on your site in a given period. For small sites it rarely matters. For large ecommerce or publishing sites with hundreds of thousands of URLs, wasted crawling can delay the discovery of new content. Blocking low-value areas helps crawlers focus on pages that deserve attention, and it reduces the load on your server.
The best way to see whether this is happening on your own site is server log file analysis. Your access logs record every request, including those from Googlebot, along with the URL and the response code. Filter for Googlebot, and remember to verify the requests, because fake bots often copy Google's name. Reverse DNS lookups or Google's published IP ranges will tell you which requests are genuine.
Once you have a clean set of Googlebot hits, look for patterns. Are thousands of requests going to parameter URLs, internal search pages, or old redirects? That is crawl waste. Genuine crawl demand looks different: Googlebot returning often to your category pages, new articles, and updated products. After you change robots.txt, compare the logs from a few weeks before and after. If the change worked, crawling of the blocked patterns drops and attention shifts toward pages you care about. Keep in mind that a disallowed URL should not receive Googlebot requests at all, other than for the robots.txt file itself, so repeated hits on a blocked path usually point to a caching delay or an impostor.
Managing Unnecessary and Low-Value URL Crawling
Filtered category pages, session IDs, sorting parameters, and internal search results can create near-endless URL combinations. These rarely deserve to be crawled. A few targeted disallow rules can prevent crawling loops while leaving your core pages untouched.
This is where ecommerce sites run into trouble. Faceted navigation lets shoppers filter by size, color, brand, and price, and every combination can generate a new URL. Three filters with ten options each can produce thousands of pages that show nearly identical products. Left alone, this leads to a URL explosion and crawl traps, where a bot follows filter links in an endless chain. Product variants add to the problem by creating several URLs for essentially one item.
Robots.txt is one tool for handling it, but not the only one. Canonical tags help consolidate duplicate versions, yet Google can only read a canonical tag if it is allowed to crawl the page, so blocking a URL in robots.txt and also relying on its canonical tag is contradictory. A sensible approach is to block clearly useless parameter patterns, such as sorting and session IDs, and use canonical tags for filter combinations you want Google to understand. Be careful with pagination. Paginated category pages are often the only route to deeper products, so blocking them can hide those products from crawlers. Filtering parameters and pagination parameters should be treated separately.
How Robots.txt Affects Search Engine Visibility
Used well, the file has no visible effect on rankings because it simply keeps things tidy. Used badly, it can wipe out visibility. A single stray slash can block an entire site, and blocking CSS or JavaScript can stop Google from rendering your pages properly. The file is small, but the consequences of a mistake are large.
Robots.txt Directives and Syntax Explained
Robots.txt syntax is simple. Each rule sits on its own line, written as a field name, a colon, and a value. Rules are organized into groups, and each group begins with a user-agent line.
User-agent Directive
The user-agent line names the crawler a group applies to. Use `User-agent: Googlebot` for Google's main crawler, `User-agent: Bingbot` for Bing, or `User-agent: *` for all crawlers that have no more specific group. The name is not case sensitive, but the paths that follow are.
Not every crawler is the same, and the differences affect how you write your rules. Googlebot crawls with both a smartphone and a desktop version, but both respond to the single `Googlebot` token, so you cannot give them separate instructions. Google also runs specialized crawlers with their own tokens, including Googlebot-Image, Googlebot-Video, and Googlebot-News. If you block Googlebot, these generally follow along unless they have their own group. AdsBot, used for ad landing page quality, is an exception to watch because it ignores the `*` group and has to be named explicitly. Tools such as the URL Inspection tool and other Search testing features use their own agent, Google-InspectionTool, so a rule aimed only at Googlebot may not tell you everything about what those tools can fetch.
Then there are third-party crawlers. SEO platforms run their own bots. Moz, for instance, uses crawlers such as Rogerbot and DotBot, and tools like Screaming Frog identify themselves with their own names. These are not search engines, and blocking them has no effect on rankings. If you want to stop a particular tool from crawling your site, you can name its user agent in its own group, though a few tools let users choose whether to obey the file.
How Robots.txt Rule Matching and User-agent Groups Work
When several rules could apply, Google follows the most specific match, meaning the rule with the longest matching path. If an allow and a disallow rule are equally specific, the less restrictive one (allow) wins. Also remember that a crawler uses only the single group that best matches its name. If you create a Googlebot group, Googlebot will ignore the `*` group completely, so repeat any shared rules.
Paths are case sensitive, so `Disallow: /Private/` does not block `/private/`. Rules match from the start of the URL path, including any query string, and Google treats percent-encoded characters and their plain equivalents as the same in most cases. Even so, test any rule that involves unusual characters, spaces, or non-English URLs instead of assuming it behaves as you expect.
Disallow Directive
Disallow tells a crawler not to request a path. `Disallow: /private/` blocks everything inside that directory. An empty value, `Disallow:`, blocks nothing. A single slash, `Disallow: /`, blocks the whole site, which is exactly what you want on a staging server and exactly what you do not want on a live one.
Allow Directive
Allow creates an exception inside a blocked area. For example, you can disallow a folder but allow one file within it. It is most useful when you have blocked a broad path and need to reopen a narrow one.
Sitemap Directive
The sitemap directive points crawlers to your XML sitemap with a full URL, such as `Sitemap: https://www.example.com/sitemap.xml`. It is independent of user-agent groups, can appear anywhere in the file, and can be listed more than once. Including a sitemap in robots.txt is a simple way to help search engines find your pages.
Wildcards and URL Matching in Robots.txt
Google and Bing support two pattern characters, which help you match groups of URLs without listing each one.
**Asterisk (\*) Wildcard**
The asterisk matches any sequence of characters. `Disallow: /*?sort=` blocks any URL containing that sorting parameter, whatever comes before it.
Dollar Sign (\$) Wildcard
The dollar sign marks the end of a URL. `Disallow: /*.pdf$` blocks URLs that end in .pdf but not a URL such as `/file.pdf?download=1`.
Comments in Robots.txt
Lines beginning with a hash symbol are comments and are ignored by crawlers. They are useful for leaving notes for the next person who edits the file, for example `# Block internal search`.
Robots.txt Directives Google Does Not Support
Some directives appear in old tutorials but do nothing for Google, so it is worth knowing which ones to skip.
Crawl-delay
Crawl-delay asks a bot to wait between requests. Google ignores it, although some other crawlers, such as Bing, may respect it. Googlebot adjusts its own crawl rate based on how your server responds.
Noindex and Nofollow
Google stopped supporting noindex and nofollow inside robots.txt in 2019\. Putting them there has no effect. Use meta robots tags or HTTP headers instead.
Robots.txt Examples for Different Website Scenarios
These robots.txt examples cover the situations you are most likely to meet. Adjust paths to match your own site.
Allow All Search Engine Crawlers
``` User-agent: * Disallow: ```
This lets every crawler access everything. It is the same as having no file, but it confirms your intent.
Block All Search Engine Crawlers
``` User-agent: * Disallow: / ```
Use this on development or staging sites only. Never leave it on a live site by accident.
Block a Specific Directory
``` User-agent: * Disallow: /admin/ ```
Block a Specific Page or File
``` User-agent: * Disallow: /thank-you.html ```
Allow a Specific Page Within a Blocked Directory
``` User-agent: * Disallow: /resources/ Allow: /resources/guide.html ```
Block URLs With Specific Parameters
``` User-agent: * Disallow: /*?sessionid= Disallow: /*&sort= ```
Parameter rules need care. Check that they do not catch URLs you want crawled, such as paginated content that matters. On a store with faceted navigation, list the parameters one by one, test each against real URLs, and avoid a blanket rule that blocks every query string.
Complete Robots.txt Example for a Typical Website
``` # Rules for all crawlers
User-agent: * Disallow: /admin/ Disallow: /cart/ Disallow: /search/ Disallow: /*?sort= Allow: /admin/help.html
Sitemap: https://www.example.com/sitemap.xml ```
This sample robots.txt file blocks common low-value areas, keeps one exception, and points to the sitemap. It is a reasonable starting point rather than a template to paste blindly.
How to Create a Robots.txt File
You do not need special software. A basic text editor is enough, and many people also use a robots.txt generator to draft the first version.
Step 1: Identify Which Pages and Files to Control
Start by listing areas that offer no search value: login pages, checkout steps, internal search, duplicate filtered views, and private folders. Also note anything that should stay crawlable, especially pages that earn traffic.
Step 2: Choose the User-agents and Directives
Decide whether the rules apply to all bots or only to certain ones. Most sites do fine with a single `*` group. Add separate groups only when you have a clear reason, such as limiting a particular crawler.
Step 3: Create and Write Your Robots.txt File
Open a plain text editor, write your groups, and save the file as `robots.txt` with UTF-8 encoding. Avoid word processors, which can add hidden formatting. Keep one directive per line, leave a blank line between groups, and double-check spelling, since a misspelled directive is silently ignored.
Step 4: Upload Robots.txt to Your Website's Root Directory
Upload the file to the root of your domain through FTP, your hosting file manager, or your CMS. It must be reachable at `yourdomain.com/robots.txt`.
Step 5: Verify That Your Robots.txt File Is Accessible
Open the URL in a browser. You should see the plain text and receive a 200 status. Then run it through a tester or the Google Search Console report to confirm it is parsed as expected.
Do not stop at the origin server. If you use a CDN or proxy, request the file from outside your network and confirm that the live version matches what you uploaded. After every deployment, repeat this quick check, because build tools and hosting setups sometimes overwrite the file or serve different versions from different servers.
How to Add Robots.txt to Different Platforms
The method depends on your platform, and many systems create a default file for you.
How to Add Robots.txt in WordPress
WordPress generates a virtual robots.txt file by default. To edit it, you can use an SEO plugin such as Yoast SEO or Rank Math, which includes a file editor, or upload a physical file to your root directory through FTP. A typical WordPress robots.txt example blocks `/wp-admin/` while allowing `/wp-admin/admin-ajax.php`, since some themes and plugins rely on it.
How to Add Robots.txt in Other Platforms
Shopify creates a default file and lets you customize it through the robots.txt.liquid template. Blogger offers a custom robots.txt setting inside its search preferences. Wix and Squarespace provide editors in their SEO settings. For a React or other JavaScript app, place a static robots.txt file in the public folder so it is served from the root.
Robots.txt Best Practices for SEO
A few habits prevent most problems.
Use Specific Rules to Avoid Blocking Important URLs
Broad rules catch more than you expect. Block exact folders or patterns, and avoid short prefixes that match unrelated pages.
Don't Block Important CSS, JavaScript, and Image Resources
Google needs to load these files to understand how your pages look and behave. Blocking them can lead to a "blocked internal resources in robots.txt" warning and weaker rendering.
The reason comes down to how Google processes pages. Crawling and rendering are separate stages. Googlebot first fetches the raw HTML, then the page may wait in a render queue before Google's rendering service runs the JavaScript and builds the final page. If your scripts or stylesheets are blocked, that second stage works with incomplete information. This can affect discovery as well. Many modern sites generate navigation, product lists, or internal links with JavaScript, and if the script that creates those links is blocked, Google may never see them. The result is a gap between the initial HTML and the rendered HTML, and pages that depend on that gap can be under-indexed or misunderstood.
You can check this yourself. In the URL Inspection tool, view the crawled page and compare the rendered HTML and screenshot with what a visitor sees. Missing content or a broken layout often points to a blocked resource.
Don't Use Robots.txt to Hide Sensitive Information
The file is public. Anyone can read it, and listing a secret folder actually advertises its location. Protect private content with authentication, not with a disallow rule.
Use Wildcards Carefully
A misplaced asterisk can block far more than intended. Test each pattern against real URLs before publishing.
Keep Your Robots.txt File Updated
Review the file after site migrations, redesigns, and platform changes. Old rules often outlive the structure they were written for.
Migrations deserve extra attention because this is where the costliest errors happen. Staging and development sites are usually set to disallow everything, and that file can travel to production with the rest of the code. Before launch, compare the production file with the staging one and confirm the live version allows crawling. During a domain migration, the old domain's robots.txt should not block crawling, since Google needs to reach the old URLs to see their redirects to the new ones. Meanwhile, the new domain needs rules that match its new URL structure, not leftovers from the old one.
It also helps to plan for failure. Keep the file in version control so you can see who changed what and when. If a bad file goes live, roll back to the last good version, purge any CDN cache, and check the live file immediately. You can then use the robots.txt report in Search Console to request a recrawl so Google picks up the fix sooner.
Use Separate Robots.txt Files for Different Subdomains
`blog.example.com` and `www.example.com` are treated as separate hosts, so each needs its own file. The same logic applies to different protocols and ports, as explained earlier, so make sure no variation of your domain serves unexpected rules.
Target Specific Search Engine and AI Crawlers When Necessary
Many site owners now use robots.txt to manage AI crawlers, but the choice is not a single on or off switch. These bots do different jobs, and it helps to separate them into three groups.
Training crawlers collect content to help build language models. GPTBot from OpenAI and CCBot from Common Crawl are examples. Search crawlers index content so it can appear in AI-powered search results. OAI-SearchBot is one example. User-triggered retrieval bots fetch a page only when a person asks for it, as with ChatGPT-User, and these may not follow robots.txt in the same way as automated crawlers, since a person initiated the request. Anthropic also publishes separate crawler names for training, search, and user requests, so check each company's documentation for current names.
Google adds another layer. Googlebot crawls for Google Search and is a separate matter from Google-Extended, which is a control token that tells Google whether your content can be used for certain generative AI purposes. Blocking Google-Extended does not remove your pages from Search, and it does not change how Googlebot crawls them.
The trade-off is worth thinking through. Blocking training bots may limit how your content is used to build models, while blocking search crawlers could reduce your visibility in AI-driven answers. Decide based on your goals, and remember that compliance is voluntary. The newer llms.txt file is a different idea altogether: it suggests content for language models to read, while robots.txt sets crawl permissions.
Common Robots.txt Mistakes and How to Fix Them
Accidentally Blocking the Entire Website
A leftover `Disallow: /` from a staging environment is the classic cause of sudden traffic loss. Remove it, retest, and request a recrawl of key pages. Check your deployment process so the development file cannot be published to the live site again.
Blocking Important Pages From Search Engine Crawlers
If Search Console reports pages as "blocked by robots.txt" and you want them indexed, find the rule responsible and narrow or remove it.
Using Incorrect Wildcard Patterns
Forgetting the `$` end marker or adding extra asterisks often blocks unintended URLs. Rewrite the pattern and test it.
Placing Robots.txt in the Wrong Directory
A file in a subfolder is ignored. Move it to the root and confirm it loads at the correct URL on the correct protocol, host, and port.
Using Unsupported Directives
Remove noindex, nofollow, and crawl-delay lines if you expect Google to act on them. Move indexing control to meta tags or headers.
Blocking Resources Required for Page Rendering
If Google cannot load your scripts and styles, it may misjudge the page. Allow those paths, then use the URL Inspection tool to check the rendered result.
How to Test and Audit Your Robots.txt File
How to Check Your Robots.txt File in a Browser
Type your domain followed by `/robots.txt`. This is also how to find robots.txt on any site, and it shows exactly what crawlers see.
How to Check Robots.txt Using Google Search Console
Search Console includes a robots.txt report under Settings. It shows which files Google found, when they were last fetched, and any parsing errors or warnings. For checking a single URL, the URL Inspection tool tells you whether crawling is allowed.
How to Identify URLs Blocked by Robots.txt
The Page indexing report lists URLs marked "Blocked by robots.txt." Review that list to confirm every blocked URL is intentional. Crawling tools such as Moz Pro and other site audit software can also flag blocked pages, and Moz's crawler obeys the file, so an unexpected block there may point to a rule worth reviewing.
How to Fix Robots.txt Crawling Errors
Identify the failing rule or response, correct it, upload the new version, and recheck the report. If a crawler cannot fetch the file at all, start by fixing server errors before touching the rules. When the file looks right on your server but crawlers still see old rules, clear the CDN cache and check whether different servers are returning different versions.
Understanding Robots.txt HTTP Errors and File Size Limitations
How the server responds to a request for the file changes how crawlers behave, so the status code matters as much as the content.
A 200 response means the file was delivered and its rules apply. Redirects are followed, and Google will follow several hops, around five, before giving up and treating the file as missing. Long redirect chains and redirects to a different host are best avoided, since they add risk and delay for no benefit. Client errors in the 4xx range, including 401 and 403 access denied responses, are generally treated as if no robots.txt exists, which means crawling is unrestricted. That is a common surprise for sites that password-protect an entire staging area and assume crawlers will stay out.
Server problems are handled very differently. A 5xx error, and also a 429 Too Many Requests response, tells Google the site may be struggling. Google can temporarily treat the whole site as off limits and pause crawling until the file loads again. If the errors continue for a long stretch, Google may fall back on a previously cached copy, and eventually it may proceed as though there are no restrictions. A rate limiter or firewall that throttles bots can therefore interfere with crawling simply by blocking requests for this one small file.
Google also reads only the first 500 KiB of the file, and anything beyond that is ignored, so keep it concise.
How Often Should You Audit Robots.txt?
Check it after any major site change and review it at least a few times a year. A quick look is cheap compared with recovering from lost traffic. If you manage a large site, pair this with a periodic review of your log files so you can confirm that crawlers are behaving the way your rules intend.
Robots.txt vs. Noindex vs. X-Robots-Tag
These tools solve different problems, and mixing them up causes most indexing confusion.
Robots.txt vs. Meta Robots Noindex
Robots.txt controls crawling. The meta robots noindex tag controls indexing. If you block a page in robots.txt, Google cannot see its noindex tag, so the two should not be combined on the same URL.
Robots.txt vs. X-Robots-Tag
The X-Robots-Tag is an HTTP header that does the same job as a meta tag but also works for non-HTML files such as PDFs and images.
Robots.txt vs. Password Protection
Password protection actually restricts access. Robots.txt only asks politely. For anything confidential, use authentication.
When Should You Use Each Method?
Use robots.txt to manage crawl activity, noindex or X-Robots-Tag to keep pages out of search results, and password protection for private content.
Frequently Asked Questions About Robots.txt
Is Robots.txt Necessary for Every Website?
No. Small sites with nothing to block can function without one. Still, having a simple file with a sitemap line is good practice.
Can Robots.txt Block Googlebot?
Yes. Use User-agent: Googlebot with a disallow rule. Be careful, because blocking Googlebot can remove your content from Google's crawl entirely.
Can Robots.txt Protect Private Website Content?
No. The file is public and not enforced. Use passwords or server-level restrictions instead.
Can Robots.txt Block AI Crawlers?
It can ask reputable AI crawlers to stay away if they honor the protocol and you name their user agents. Because training, search, and user-triggered bots have different names and purposes, decide which of them you want to allow before writing the rules. Bots that ignore the standard will not be stopped.
Does Robots.txt Affect Website Rankings?
Not directly. Its influence comes from how it shapes crawling and rendering. Blocking important pages or resources can hurt visibility, while a clean file simply supports efficient crawling. Permissions for AI crawlers do not affect your Google rankings, though they may influence how your content is used or surfaced in AI search products.
How Can I Find Another Website's Robots.txt File?
Add /robots.txt to the end of the domain in your browser. Most public sites make the file available, and it is a handy way to see how other sites handle similar rules.
Conclusion
Robots.txt is a simple but important file that helps website owners manage how search engine crawlers access their websites. When configured correctly, it can reduce unnecessary crawling, support crawl budget management, and help search engines focus on important website sections. However, incorrect rules can block valuable pages or resources and negatively affect search visibility. Follow robots.txt best practices, test your directives before publishing, and review the file regularly to avoid crawling issues. As part of a broader technical SEO strategy, a properly maintained robots.txt file helps support a healthy and search-friendly website.




