What Is Robots.txt

September 5, 2026

Svelte code displayed on a dark computer screen in a code editor

Photo by Ferenc Almasi on Unsplash

A single misplaced line in a robots.txt file can prevent search engines from crawling the pages you need to rank. Used correctly, this small plain-text file helps guide search-engine bots toward valuable content and away from low-value, private, or resource-intensive URLs. Used carelessly, it can quietly undermine organic visibility across an entire website.

What Is a Robots.txt File?

A robots.txt file is a text file that gives search-engine crawlers instructions about which parts of a website they may or may not crawl. It uses the Robots Exclusion Protocol, a widely recognized convention followed by major search engines and SEO crawlers.

Its primary purpose is crawl management. Rather than wasting crawl activity on pages that offer little search value, such as login pages, filtered navigation URLs, or internal site-search results, you can direct bots toward the pages that matter most.

It is important to understand that robots.txt is a request, not a security control. Major reputable crawlers generally support its directives, but search engines are not universally required to obey them. Never use robots.txt to protect confidential documents, customer data, passwords, or other sensitive information. Use authentication, server permissions, or proper access controls instead.

Where Robots.txt Belongs and How Its Syntax Works

Your robots.txt file must sit in the root directory of the website’s host. For example, it should be available at:

https://www.example.com/robots.txt

It cannot be placed in a subfolder such as /blog/robots.txt or /assets/robots.txt and still control the entire site. Each protocol and subdomain may require its own file. For example, https://example.com and https://www.example.com can be treated as separate hosts.

A basic robots.txt file uses simple directives:

  • User-agent: Identifies the crawler the rule applies to, such as Googlebot. An asterisk (*) means all crawlers.
  • Disallow: Requests that a crawler not access a URL path.
  • Allow: Permits crawling of a specific path, often when it sits within a disallowed directory.
  • Sitemap: Supplies the URL of your XML sitemap to help search engines discover important pages.

Here is a simple example:

User-agent: *
Disallow: /admin/
Disallow: /search/
Allow: /admin/public-resource.html
Sitemap: https://www.example.com/sitemap.xml

Keep rules clear, deliberate, and documented. A blank Disallow: directive means the crawler is allowed to crawl everything under that user-agent group.

Robots.txt, Crawling, Indexing, and Noindex Are Not the Same

One of the most expensive technical SEO mistakes is confusing crawl blocking with index prevention. A Disallow rule tells a compliant crawler not to fetch a URL. It does not reliably guarantee that the URL will never appear in search results.

If Google or another search engine discovers a blocked URL through internal links, external backlinks, XML sitemaps, or other signals, that URL can still potentially appear in search results. The search engine may show a limited result because it could not crawl the page content.

To keep an accessible page out of search indexes, use a meta robots noindex tag in the page’s HTML:

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

You can also send an X-Robots-Tag HTTP header for non-HTML files such as PDFs. Crucially, search engines need to crawl a page to see its noindex directive. Do not block a URL in robots.txt if your goal is for Google to crawl it, process its noindex instruction, and remove it from indexing over time.

Practical Robots.txt Use Cases

Robots.txt is most useful when it reduces needless crawling without hiding valuable content. Common, sensible applications include:

  • Administrative areas: Request that bots avoid paths such as /admin/, /wp-admin/, account dashboards, and login-related paths.
  • Internal search results: Block internal search URL patterns that create thin, repetitive pages with little standalone value.
  • Staging and development paths: Prevent accidental crawling of non-public test environments. Better yet, protect staging environments with password authentication and noindex controls.
  • Duplicate parameter URLs: Limit crawling of faceted navigation, tracking parameters, sorting options, and session-based URLs when they generate near-duplicate content.
  • Non-public or low-value resources: Reduce crawler access to utility directories, certain scripts, temporary files, and other pages that should not consume crawl budget.

Before blocking parameterized URLs, assess canonical tags, internal linking, pagination, and your site architecture. An overly broad rule can block product pages, category filters with search demand, or other URLs that support conversions.

How to Create, Test, and Validate Robots.txt Rules

Start by auditing your site’s current URL structure. List essential organic landing pages, assets required for rendering, private sections, internal search paths, and duplicate URL patterns. Then write the smallest set of rules needed to address real crawl issues.

After uploading the file to the root domain, verify that it loads with a browser and returns a successful server response. Next, use Google Search Console to inspect important URLs and determine whether Google reports that crawling is blocked by robots.txt. Search Console’s reporting and URL Inspection tools can help identify blocked resources and crawl-related issues.

You should also test the site with reputable SEO crawling tools. Configure a crawler to respect robots.txt first, then compare that crawl with a controlled diagnostic crawl where appropriate. This helps reveal whether key pages, CSS files, JavaScript resources, images, or canonical URLs are being unintentionally excluded.

Whenever you change robots.txt, validate your highest-priority pages immediately: homepage, service or product pages, category pages, blog posts, XML sitemaps, and mobile resources. Monitor crawl reports and index coverage afterward rather than assuming the change worked as intended.

Common Robots.txt Mistakes to Avoid

Blocking Important Pages or Entire Sections

A rule such as Disallow: / blocks compliant crawlers from the entire site. This is sometimes used temporarily during development but can be disastrous if it reaches production. Review deployment settings carefully and maintain version control for technical SEO files.

Blocking CSS and JavaScript Files

Search engines often need CSS and JavaScript resources to render pages accurately and assess the user experience. Blocking essential assets can make it harder for crawlers to understand layout, content, structured data, and mobile functionality. Only restrict resources after confirming they are unnecessary for rendering and search visibility.

Using Wildcards Incorrectly

Some crawlers, including Google, support pattern matching such as the wildcard * and the end-of-URL marker $. However, pattern behavior must be written precisely and checked against current search-engine documentation. A broad rule can affect far more URLs than expected, especially on ecommerce and content-heavy sites.

Assuming a Blocked URL Cannot Rank

Robots.txt controls crawling, not guaranteed index exclusion. If a page must stay out of Google search results, use noindex on a crawlable page or restrict access at the server level when the content is genuinely private.

Robots.txt FAQ

What does a robots.txt file do?

It provides crawler access instructions for sections of your website. It is primarily a crawl-management tool, helping search engines avoid URLs that should not be fetched or that provide limited SEO value.

Where should robots.txt be placed on a website?

Place it at the root of the host, such as https://www.example.com/robots.txt. A robots.txt file inside a subdirectory will not govern the full site.

Does robots.txt stop a page from appearing in Google search results?

Not necessarily. A blocked URL may still be discovered through links or other signals and can potentially appear in search results. Use a crawlable noindex directive when index exclusion is the objective.

How do I know whether my robots.txt file is blocking Google?

Check the file directly in your browser, inspect affected URLs in Google Search Console, and run a technical crawl using an SEO crawler that reports robots.txt exclusions. Test critical URLs after every change.

What is the difference between robots.txt and a meta robots noindex tag?

Robots.txt asks bots not to crawl a URL or path. A meta robots noindex tag asks search engines not to include a crawled page in search results. Since crawlers need access to read noindex, avoid using both directives on the same URL when deindexing is your goal.

Ready to see how your site stacks up? Run a free SEO audit and get a clear picture of what's holding your rankings back.

Want to know how your site stacks up?

Get a free instant SEO audit...

Get Your Free Audit →
Share this article:X / TwitterLinkedInFacebook