← Blog | November 29, 2026

How to Create a robots.txt File Step by Step (With Free Generator)

Behind every website, there is a small plain text file that most visitors never see. It is called robots.txt, and it tells search engine crawlers which parts of your site they should and should not visit. It is tiny, but one wrong line can hide your whole website from search, so it is worth learning to write it carefully.

In this step by step guide you will learn what the file does, how its few simple rules work and how to create and upload one. You can generate a ready file in a few seconds with our free Robots.txt Generator. If you want to understand how it differs from a sitemap, read our guide on the difference between a sitemap and robots.txt.

What robots.txt does

Search engines use automated programs, called crawlers or bots, to visit pages and collect information. When a well behaved crawler arrives at your site, it first looks for a file at yoursite.com/robots.txt. If the file exists, the crawler reads the rules and follows them. The rules are not a lock. They are polite requests, and the major search engines respect them. Google explains the basics in its robots.txt introduction.

Where the file must live

The file must sit at the root of your website and must be named exactly robots.txt, all lowercase. A file placed in a sub folder, such as yoursite.com/blog/robots.txt, will not be used. On a simple static website like ours, you create the text file and put it in the main folder, right next to your home page file.

The four lines you need to know

LineWhat it means
User-agentWhich crawler the rules are for. A star means all crawlers.
DisallowA folder or page the crawler should not visit.
AllowA path that may be visited, even inside a blocked folder.
SitemapThe full web address of your sitemap file.

The formal rules of the standard are written in RFC 9309, if you ever want the technical details.

Three example files

1. Allow everything. This is the simplest file and is fine for most small sites:

User-agent: *
Disallow:

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

2. Block a private folder. Useful for admin or test areas:

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

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

3. Block everything. Only use this for a site that is not ready to launch:

User-agent: *
Disallow: /

That last line is the dangerous one. A single slash after Disallow blocks the entire site, and many websites have lost traffic after leaving it on by mistake.

How to create the file with our free tool

  1. Open the Robots.txt Generator.
  2. In the first box, type the folders you want to block, one per line, for example /admin/. Leave the box empty if you do not want to block anything.
  3. Add your sitemap address in the second box, if you have one.
  4. Press Generate.
  5. Copy the result into a plain text file and save it as robots.txt.

Our generator creates one set of rules for all crawlers. If you need different rules for a specific bot, add another block by hand under its own User-agent line.

How to upload and check it

  1. Put the file in the root folder of your website, with your other main files.
  2. Upload your site as usual. If you use a zip upload on a host like Cloudflare Pages, the file must be inside the zip at the top level, not inside another folder.
  3. Open yoursite.com/robots.txt in your browser. You should see the text.
  4. Check it in Google Search Console, where the robots.txt report shows whether Google can read it.

What robots.txt cannot do

This is the part many beginners miss. Robots.txt controls crawling, not indexing. If you block a page, search engines may still list its address if other sites link to it, just without a description. To keep a page out of search results, use a noindex tag, or protect the page with a password. Google says this clearly in its guide on how to create a robots.txt file.

A real example for a small website

A small site with no private areas can use a very short file. This is the kind of file our own site uses:

User-agent: *
Allow: /

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

It tells every crawler that the whole site may be visited, and it points them to the sitemap. Nothing more is needed. Short files are easier to check, and there is less room for mistakes.

Two special characters: star and dollar

Google understands two helpful symbols in paths. The star means "any text," and the dollar sign means "the address ends here." For example:

User-agent: *
Disallow: /search*
Disallow: /*.pdf$

The first line blocks every address that starts with /search. The second blocks any address that ends in .pdf. Use these carefully, and always test them, because a pattern can match more pages than you expect.

What happens when two rules clash?

If one rule blocks a folder and another allows a page inside it, Google follows the most specific rule, which means the one with the longer matching path. For example, a rule that blocks /files/ and another that allows /files/guide.html would let the guide be crawled. It is best to keep your rules simple enough that you never need to think about clashes.

Robots.txt, noindex or a password?

GoalBest tool
Ask crawlers to skip a folderrobots.txt
Keep a page out of search resultsA noindex tag on the page
Keep a page truly privateA password or login

Common mistakes

Do you need a robots.txt at all?

If your site has nothing to hide from crawlers, you can run without one, and search engines will crawl everything. Still, a simple file is a good habit. It shows where your sitemap is, and it gives you one place to add rules later. You can build the sitemap with our Sitemap XML Generator.

Quick answers

Does Google follow the crawl delay line? No. Google ignores it, so do not rely on it.

Can I have more than one sitemap line? Yes, you can list several.

Is the generator free? Yes. It needs no signup and runs in your browser.

Final thoughts

A good robots.txt is short and careful. Use the generator, keep the rules simple, test the result and review it when your site changes. To help more people find the pages you open to search engines, take a look at our link building service, and read our guide to adding a FAQ section for SEO next.

Open the Robots.txt Generator Back to Blog