Back to Blog
    Digital Marketing12 October 2026

    robots txt example

    robots txt example

    Last updated: 12 October 2026

    A robots.txt file tells search engine crawlers which parts of your website they are allowed to visit and which they should skip. It sits at the root of your domain (yoursite.co.uk/robots.txt), is read before any other file on the site, and takes effect immediately once saved. Used correctly, it protects crawl budget and keeps sensitive areas private from bots. Used carelessly, it can silently block Google from indexing pages you need to rank.

    Key takeaways

    • Every robots.txt file must live at the exact URL yoursite.co.uk/robots.txt to be found by crawlers.
    • A Disallow directive stops compliant bots from crawling a URL, but it does not remove that URL from Google's index if other sites link to it.
    • Blocking the wrong path with robots.txt is one of the most common causes of pages disappearing from search results.
    • The file uses User-agent to target specific crawlers (e.g. Googlebot) or all bots at once with the wildcard User-agent: *.
    • Sensitive files such as admin panels, staging environments and internal search results pages are the most legitimate candidates for a Disallow rule.
    • Adding your XML sitemap URL inside robots.txt is best practice and helps Google discover your page inventory efficiently.

    What does a robots.txt file actually do?

    A robots.txt file is a plain text file that follows the Robots Exclusion Protocol, a standard introduced in 1994. When a crawler arrives at your domain, it checks robots.txt first, reads the instructions, and decides which URLs to visit. The file is public: anyone can view yours by typing your domain followed by /robots.txt into a browser.

    The key word in that definition is "compliant". Google, Bing and most major search engines respect the file. Badly behaved scrapers and spam bots typically ignore it. This means robots.txt is a traffic management tool for legitimate crawlers, not a security layer.

    What it controls is crawling, not indexing. A URL blocked by robots.txt can still appear in Google's index if another website links to it. Google will list the URL but cannot see the content, which often produces the unhelpful "no information about this page" snippet in search results. If you want a page removed from the index entirely, a noindex meta tag on the page itself is the right tool, as we cover in the related article on pages that are hard to index.

    What is a robots.txt example that actually works?

    Here is a clean, real-world robots.txt example for a small business website:

    User-agent: *
    Disallow: /admin/
    Disallow: /staging/
    Disallow: /internal-search/
    Disallow: /checkout/thankyou
    Allow: /
    
    Sitemap: https://www.yoursite.co.uk/sitemap.xml
    

    Breaking this down line by line:

    • User-agent: * applies the rules below to every crawler.
    • Disallow: /admin/ blocks the admin panel from all bots.
    • Disallow: /staging/ keeps draft content away from Google.
    • Disallow: /internal-search/ stops crawlers wasting budget on dynamically generated search results pages that carry no unique content.
    • Disallow: /checkout/thankyou keeps confirmation pages private.
    • Allow: / explicitly permits access to everything else (often implicit but good practice).
    • Sitemap: points Google directly to your sitemap.

    A User-agent block followed by Disallow: with nothing after it means "allow everything" for that agent. That is a legitimate way to grant full access to a specific bot while restricting others.

    What should you include in a robots.txt file?

    Admin and backend directories. Any URL path that leads to a CMS login, database interface or server configuration should be disallowed. These pages have no SEO value and represent an unnecessary crawl drain.

    Staging and development environments. If your staging site shares a domain with your live site under a subdirectory (e.g. /staging/), block it. If it sits on a subdomain (e.g. staging.yoursite.co.uk), it needs its own robots.txt file, or you should password-protect the environment entirely.

    Internal search results. Pages generated by an on-site search query, such as yoursite.co.uk/search?q=shoes, are typically duplicate or thin content. Allowing Googlebot to crawl thousands of them wastes crawl budget on pages that will never rank.

    Faceted navigation URLs. On e-commerce or catalogue sites, filter combinations (colour, size, price) often generate hundreds of near-identical URLs. Blocking these prevents crawl budget from being consumed by low-value parameter pages.

    Thank-you and confirmation pages. Order confirmations and form submission receipts have no ranking potential. Blocking them keeps the crawl focused on pages that matter.

    Your sitemap location. This belongs in robots.txt as a Sitemap: directive. It is the fastest way to make sure Google knows where to find your full list of pages.

    What should you never put in a robots.txt file?

    Pages you want to rank. This sounds obvious, but CMS platforms and well-meaning developers routinely add Disallow: / to an entire site during a build and forget to remove it before launch. At Revolve, this is one of the first checks in any SEO review because a single line can silently remove an entire site from Google's index.

    CSS and JavaScript files. Blocking stylesheets and scripts was common advice before Google began rendering pages. Today, Googlebot renders pages the way a browser does. If it cannot access your CSS or JavaScript files, it may misinterpret your page structure, miss content loaded dynamically, and rank your pages poorly as a result.

    Your canonical or hreflang pages. If a page carries a canonical tag pointing to another URL, or an hreflang tag for language targeting, Google needs to be able to crawl both the source and the target to understand the relationship. Blocking either breaks the signal.

    Individual product pages or blog posts you simply want to deprioritise. Robots.txt is a blunt instrument. If a page is worth publishing, it is almost always worth letting Google see it. Use canonical tags, noindex or internal link weighting to deprioritise low-priority content instead.

    Passwords, API keys or credentials. Robots.txt is a public file. Never place sensitive strings in it on the assumption that only bots will read it.

    Robots.txt vs noindex vs canonical: which does what?

    These three tools are often confused because they all influence which pages appear in Google's index. They operate at different points in the process and should not be treated as interchangeable.

    Tool What it controls Removes from index? Requires crawl access?
    robots.txt Disallow Crawling only No No
    noindex meta tag Indexing Yes, over time Yes (must be crawled to be read)
    Canonical tag Which URL is the preferred version Consolidates, not removes Yes (both URLs must be crawlable)

    The practical rule: block crawling with robots.txt when you do not want the content visited at all (admin, staging). Use noindex when the page can be crawled but should not appear in search results. Use canonicals when the content exists at multiple URLs and you want to consolidate ranking signals to one of them.

    How do you write a robots.txt file step by step?

    1. Open a plain text editor (Notepad on Windows, TextEdit in plain text mode on a Mac).
    2. Write User-agent: * on the first line to address all crawlers, then list any Disallow or Allow directives below it.
    3. If you want to give different instructions to a specific crawler (for example, blocking only Googlebot from a path), add a separate User-agent: Googlebot block with its own rules.
    4. Add your sitemap URL on a line by itself: Sitemap: https://www.yoursite.co.uk/sitemap.xml.
    5. Save the file as robots.txt with no other extension.
    6. Upload it to the root directory of your domain, not a subdirectory.
    7. Visit yoursite.co.uk/robots.txt in a browser to confirm the file is accessible and readable.
    8. Test the file using Google Search Console's robots.txt tester to check that the correct URLs are blocked and the correct ones are permitted.

    One detail that causes silent failures: the path in a Disallow directive is case-sensitive. Disallow: /Admin/ will not block /admin/ on a case-sensitive server. Always match the exact case of your actual URLs.

    What are the risks of getting robots.txt wrong?

    Accidental site-wide blocking. The line Disallow: / with User-agent: * blocks every bot from every page. It takes seconds to add and can take days to notice if nobody checks Google Search Console regularly.

    Blocking resources Googlebot needs to render pages. As noted above, preventing access to CSS or JavaScript means Google renders a broken version of your site. Pages may look fine to a visitor but broken to a crawler.

    False sense of security. Because the file is public and only honoured by compliant bots, it provides no protection against scrapers or malicious actors. Treat it as a crawler management tool only.

    Crawl budget misdirection. Blocking nothing at all on a large site with thousands of parameter-generated URLs means Googlebot may spend its entire crawl budget on low-value pages and never reach newer or more important content.

    Conflicts with noindex tags. A page blocked in robots.txt that also carries a noindex tag presents a contradiction: Google cannot crawl the page to read the noindex instruction. The result is that the page may stay in the index indefinitely, because Google has no way of knowing it carries a noindex tag.

    Frequently Asked Questions

    Does every website need a robots.txt file? No, but it is best practice to have one. If a crawler does not find a robots.txt file, it treats the entire site as open for crawling. For most small business sites this is fine, but a robots.txt that explicitly allows everything and includes the sitemap location is still worth adding because it confirms your intent and helps Google find your content faster.

    Can robots.txt block Google from indexing a page? No. A Disallow directive stops Google from crawling a URL, but it does not remove the URL from Google's index. If other sites link to that URL, Google can still list it in search results. To remove a page from the index, you need a noindex meta tag on the page itself, or you can submit a removal request via Google Search Console.

    What happens if my robots.txt has a syntax error? Google will try to interpret the file as best it can, but the results are unpredictable. A missing User-agent line before a Disallow, or a typo in a directive name, can cause rules to be ignored or misapplied. Always test your robots.txt file using the robots.txt tester inside Google Search Console before publishing changes.

    Should I block Googlebot from my images? Generally, no. Google Images can drive meaningful referral traffic to small business sites, particularly for product photography, portfolio work or local imagery. Blocking Googlebot-Image with a disallow rule opts you out of that traffic entirely. Only block image directories if those images are genuinely private or add no search value.

    How long does it take for robots.txt changes to take effect? Googlebot re-crawls robots.txt regularly, typically within a few hours to a few days. However, the effects of a change (such as unblocking a previously disallowed section) can take longer to show up in search results because the newly accessible pages then need to be crawled and indexed. Urgent changes should be accompanied by a manual crawl request in Google Search Console.

    Can I have multiple User-agent blocks in one robots.txt file? Yes. You can write separate blocks for different crawlers. For example, you might block Bing's bot (Bingbot) from certain paths while leaving Googlebot unrestricted, or vice versa. Each block begins with its own User-agent: line followed by the relevant Allow and Disallow directives. The wildcard User-agent: * applies to any crawler not addressed by a more specific block.

    Is it safe to copy someone else's robots.txt file? Only as a starting point. Another site's file reflects its own directory structure, platform and content strategy. A path like /wp-admin/ only makes sense if you run WordPress. Copying wholesale without reviewing each directive against your own site's structure risks blocking pages you need Google to crawl, or allowing access to directories that should be private.

    Author: This guide was written by the SEO and content team at Revolve, a digital marketing agency based in Banbury, Oxfordshire. Revolve works with small and mid-sized UK businesses on SEO, AEO and paid advertising.

    Last updated: 12 October 2026

    By Revolve

    Need expert support on search, paid media or measurement?

    Get in Touch →