๐Ÿ“š Links & SEO ยท Guide

How to Create a Robots.txt File: A Beginner's Guide With Examples

Learn what robots.txt does, how to build one with a free generator, and how to block the right pages without hiding your site from Google. Includes ready-to-use examples.

By RexBD Team 24 Nov 2026 7 min read 1,535 words
How to Create a Robots.txt File: A Beginner's Guide With Examples

Before Google, Bing or any other well-behaved crawler reads your website, it looks for one small file: robots.txt. This plain text file sits at the root of your domain and tells crawlers which areas of the site they may visit and which they should skip. Get it right and you keep crawlers focused on your important pages. Get it wrong and you can accidentally hide your entire website from search results.

This guide explains what robots.txt does, how to create one safely with the free Robots.txt Generator on RexBD, and which rules make sense for common types of websites.

What robots.txt is, and what it is not

Robots.txt is part of the Robots Exclusion Protocol, a standard that search engines have followed since the 1990s and which became an official internet standard (RFC 9309) in 2022. It is always found at the same place:

https://yourdomain.com/robots.txt

Crawlers request this file first. If it says a folder is off-limits, compliant crawlers will not fetch pages in that folder.

It is just as important to understand what robots.txt does not do:

  • It is not security. The file is public. Anyone can read it, and badly behaved bots simply ignore it. Never use it to hide private information. Protect private areas with a password instead.
  • It does not remove pages from Google. Blocking a page stops Google from crawling it, but if other sites link to it, Google may still list the URL without a description. To keep a page out of search results, use a noindex meta tag and let Google crawl the page so it can see that tag.
  • It does not apply across domains. Each subdomain needs its own file. shop.example.com does not follow the rules at example.com.
๐Ÿค– Free tool ยท no sign-upTry the Robots.txt GeneratorBuild a robots.txt file that tells search engines which parts of your site to crawl. Open tool โ†’

The parts of a robots.txt file

A robots.txt file is made of groups of rules. Each group starts with a User-agent line saying which crawler the rules are for, followed by Disallow and Allow lines.

User-agent: *
Disallow: /admin/
Disallow: /cart
Allow: /

Sitemap: https://example.com/sitemap.xml
  • User-agent: * means "all crawlers". You can also target a specific bot, such as Googlebot or Bingbot.
  • Disallow: /admin/ blocks every URL that begins with /admin/.
  • Allow: / permits everything else. Allow is useful for opening one sub-folder inside a blocked folder.
  • Sitemap: points crawlers to your XML sitemap. This line can appear anywhere in the file and should use the full URL.

Paths are case-sensitive. /Admin/ and /admin/ are different paths.

How to create robots.txt with the generator

Step 1: Choose the default rule

Open the Robots.txt Generator and decide the default for all crawlers. For almost every public website, the right default is to allow everything and then block a few specific areas.

Step 2: Add the folders you want to block

Enter the paths of areas that have no value in search results. Common examples are admin panels, login pages, shopping carts, checkout steps, internal search results and temporary folders.

Step 3: Add rules for specific bots if needed

If you want different behaviour for a particular crawler, add a separate group for it. Most small sites never need this.

Step 4: Add your sitemap URL

Always include the full address of your XML sitemap. If you do not have one, you can make a simple one with the Sitemap from URL List tool.

Step 5: Copy and upload the file

Copy the generated text and save it as a plain text file named exactly robots.txt (all lowercase). Upload it to the root folder of your website, the same folder that holds your home page. Then open https://yourdomain.com/robots.txt in a browser to confirm it is live.

Ad Kothay

Ready-made examples for common websites

These examples are starting points. Adjust the paths to match your own site.

A simple business or portfolio website

User-agent: *
Disallow:

Sitemap: https://example.com/sitemap.xml

An empty Disallow line means nothing is blocked. For a small site, this is often all you need.

A WordPress website

User-agent: *
Disallow: /wp-admin/
Allow: /wp-admin/admin-ajax.php

Sitemap: https://example.com/sitemap_index.xml

The Allow line keeps a file open that some themes and plugins need for pages to work properly.

An online shop

User-agent: *
Disallow: /cart
Disallow: /checkout
Disallow: /my-account
Disallow: /*?orderby=
Disallow: /*?filter_

Sitemap: https://example.com/sitemap.xml

The last two lines use wildcards to stop crawlers wasting time on thousands of sorted and filtered versions of the same product lists.

A staging or test website

User-agent: *
Disallow: /

This blocks everything. It is right for a test site, and a disaster on a live one. The most common robots.txt accident is copying a staging site to production and forgetting to change this file. For test sites, password protection is even safer than robots.txt.

Wildcards and special characters

Google and Bing support two special characters:

  • * matches any sequence of characters. Disallow: /*?sessionid= blocks any URL containing that parameter.
  • $ marks the end of a URL. Disallow: /*.pdf$ blocks URLs that end in .pdf.

Use them carefully. A single misplaced wildcard can block far more than you intended.

What you should not block

Blocking the wrong things is worse than having no robots.txt at all. Avoid these mistakes:

  1. Do not block CSS and JavaScript files. Google renders your pages like a browser. If it cannot load your styles and scripts, it may decide your pages are broken or not mobile-friendly.
  2. Do not block pages you want to deindex. As explained above, use noindex instead, and leave them crawlable until they drop out.
  3. Do not block your images if you want traffic from Google Images.
  4. Do not use robots.txt to handle duplicate content. Canonical tags do that job better. See the Canonical Tag Generator.

Blocking AI crawlers

Many site owners now want to control whether AI companies use their content for training. Several AI crawlers publish their user-agent names and respect robots.txt, so you can block them with a group like this:

User-agent: GPTBot
Disallow: /

Each company uses its own crawler name, and the list changes over time, so check each provider's documentation for the current names. A newer, separate idea is the llms.txt file, which helps AI tools understand your site rather than block them. You can create one with the llms.txt Generator.

Testing your robots.txt

After uploading, test it:

  • Open the file in a browser and read it carefully. Check every path for typos.
  • In Google Search Console, the robots.txt report shows the version Google last fetched and any errors it found.
  • Use the URL Inspection tool in Search Console to check whether a specific important page is blocked.
  • Use the Google Index Checker to see whether key pages are in Google's index.

Google caches robots.txt for up to about 24 hours, so changes may take a day to be noticed.

A pre-launch checklist

Whenever you launch a new website or move a site to a new server, run through these checks:

  1. Open https://yourdomain.com/robots.txt and confirm it loads with no error.
  2. Make sure it does not contain Disallow: / under User-agent: * unless you truly want to block everything.
  3. Confirm the Sitemap line uses the live domain, not a test or localhost address.
  4. Check that the paths you block really exist and are spelled correctly, including capital letters.
  5. Inspect your home page and two or three key pages in Google Search Console to confirm they are allowed.

This five-minute routine prevents the most damaging robots.txt mistakes.

Robots.txt and crawl budget

Large websites with tens of thousands of URLs sometimes worry about crawl budget, the number of pages Google will crawl in a given time. Blocking endless filter combinations, session IDs and internal search pages helps Google spend its time on pages that matter. For a site with a few hundred pages, crawl budget is rarely a concern, and a simple file is best.

Our robots.txt tips and mistakes article covers more advanced patterns for large sites.

Frequently asked questions

Do I need a robots.txt file?

It is not required. Without one, crawlers assume they may crawl everything. Still, a simple file with a sitemap line is good practice and helps crawlers find your pages.

Where do I upload robots.txt?

In the root folder of your domain, so it opens at https://yourdomain.com/robots.txt. Files in sub-folders are ignored.

Will robots.txt remove a page from Google?

No. Use a noindex meta tag for that. Robots.txt only controls crawling.

Is robots.txt case-sensitive?

The file name must be lowercase, and paths inside it are case-sensitive.

How long does Google take to see changes?

Usually within a day, because Google caches the file for up to about 24 hours.

Is the RexBD Robots.txt Generator free?

Yes. It is free, needs no account and runs in your browser.

Found this useful?Share it with a friend or colleague who needs it.

Keep reading

More links & seo articles
321 free tools, one placeSEO, text, images, code, money, units and design. Private, fast and almost all in your browser.
Ad Kothay