Robots.txt Generator

Disallow rules—
Mode—
Sitemap line—

How Robots.txt Generator is calculated: User-agent: * plus one Disallow line per path, plus a Sitemap line for the sitemap address

What is a robots.txt generator?

A robots.txt generator writes the small text file that tells search engine crawlers which parts of a site they may visit and which parts they may not. You type the paths to block, one per line, and the tool writes the file: a User-agent line saying the rules apply to all crawlers, one Disallow line per path, and a Sitemap line pointing at the sitemap. The file must be uploaded to the site root as robots.txt, so it is reachable at yourdomain.com/robots.txt.

Robots.txt is the first file a crawler asks for when it visits a site. It reads the rules, and well-behaved crawlers — Google, Bing, and the rest — follow them. A path listed as Disallow is not crawled, which means its pages do not appear in search results through crawling. The file does not hide the pages from anyone else: a person can still open them directly, and a crawler that ignores the file can still read them.

This generator builds the file for the two common cases: custom rules, where you list the paths to block, and allow all, where the file says the whole site is open. The default is custom rules blocking /admin/ and /private/, with a sitemap line for https://example.com/sitemap.xml.

How robots.txt works

The file is plain text, one rule per line, and it lives at the root of the site. The first line is User-agent: *, which means the rules that follow apply to every crawler. After that comes one Disallow line per path: Disallow: /admin/ blocks everything under the admin folder, and Disallow: /private/ blocks everything under the private folder. A path that ends in a slash blocks the whole folder; a path without one blocks that exact address and everything under it.

The Sitemap line at the end is optional but useful: it tells the crawler where the sitemap is, so it can read the full list of pages on the same visit. The line is simply Sitemap: followed by the full address of the sitemap file. A crawler that reads robots.txt first will follow the sitemap line straight to the list, instead of having to guess where it is.

The rules are prefix matches. Disallow: /admin/ blocks /admin/, /admin/users, and /admin/settings, but it does not block /administrator, because that address does not start with /admin/. Disallow: /private blocks /private, /private-files, and /private/page, because all of them start with /private. That is why the trailing slash matters: it is the difference between blocking a folder and blocking everything that starts with the same letters.

Custom rules vs allow all, explained

Custom rules is the default here, and it is the right choice when parts of the site should not be crawled. The two default paths, /admin/ and /private/, are the classic examples: the admin area holds the login and the settings, and the private folder holds files that are not meant for search results. Blocking them keeps them out of the index and stops the crawler wasting time on pages that will never rank.

Allow all is the choice for a site with nothing to hide. It writes a single Disallow line with nothing after it, which means no path is blocked, and every page is open to crawlers. The file still has value: it tells the crawler the site exists, it holds the sitemap line, and it stops the crawler logging a missing robots.txt as an error. A small public site with no admin area and no private files is usually best served by allow all.

The mode switch changes the rule count directly. With the two default paths and custom mode, the count is 2 rules. Switch to allow all with the same paths typed in, and the count is 0 rules, because the paths are ignored and the file opens everything. The paths stay in the box, so switching back to custom restores the two rules at once.

A worked example: blocking two folders

Take the default values: the paths /admin/ and /private/, the sitemap address https://example.com/sitemap.xml, and custom mode. The tool reports 2 disallow rules, the mode as custom rules, and the sitemap line as included. The file it writes is five lines: User-agent: *, Disallow: /admin/, Disallow: /private/, a blank line, and Sitemap: https://example.com/sitemap.xml.

Now switch the mode to allow all, leaving the paths and the sitemap address unchanged. The tool reports 0 disallow rules and the mode as allow all, and the file becomes User-agent: *, Disallow: with nothing after it, a blank line, and the same Sitemap line. The sitemap line stays included in both modes, because the crawler should find the sitemap whether anything is blocked or not.

Clear the sitemap address as well, and the sitemap line drops out of the file, so the report says not included. The file is still valid — the sitemap line is optional — but the crawler must then find the sitemap on its own, which is slower. Keep the sitemap line whenever the site has a sitemap, and keep the address exact: a wrong address in the sitemap line is worse than no line at all. If the address needs checking, a URL encoder decoder can confirm the characters are safe.

Why robots.txt matters for every site

The first reason is crawl budget. A search engine gives each site a limited amount of crawling, and a site that wastes it on admin pages, search result pages, and duplicate addresses gets its real pages crawled less often. Blocking the useless paths with robots.txt spends the budget on the pages that matter, so new and changed pages are found faster.

The second reason is keeping private pages out of search results. An admin login page, a staging copy, or an internal tool has no business in a search result, and a single Disallow line keeps it out. It is not security — the page is still reachable by anyone who knows the address — but it stops the page appearing in front of strangers who search for the site.

The third reason is the sitemap line. A crawler that reads robots.txt first learns where the sitemap is without guessing, and the sitemap is the fastest way for it to find every page. A site with a robots.txt that points at its sitemap is found faster than a site with neither file.

Robots.txt generator vs writing the file by hand

Writing robots.txt by hand is not hard: it is five lines for a simple site, and many developers do it. The risk is the same as with any hand-written file: a missing slash that blocks too much, a typo in a path that blocks nothing, or a sitemap address that points at the wrong domain. Any of those is invisible until someone checks the file, and a single wrong slash can block the whole site.

A generator removes those errors. It writes the User-agent line, one Disallow line per path exactly as typed, and the Sitemap line with the address as given, in the right order and with the right blank line. It also counts the rules, so the difference between custom mode with 2 rules and allow all with 0 rules is visible before the file is uploaded.

Hand-writing still has a place: a large site with rules for many crawlers, or with Allow lines for specific paths, needs a hand-written file, because this generator writes the common case only. But for a small site that needs to block two folders and point at a sitemap, pasting the paths in here and uploading the result is faster and safer. The same addresses can be listed in a sitemap built by our domain name generator workflow when the site itself still needs a name.

Common mistakes with robots.txt

The most common mistake is blocking too much. A rule of Disallow: / blocks the entire site, and a rule of Disallow: /page/ blocks a folder the owner meant to keep open. One wrong slash can remove a whole site from search results, and the owner often finds out weeks later from a traffic drop. Read every Disallow line twice before uploading, and test the file after it is live.

The second mistake is treating robots.txt as security. A Disallow line does not hide a page: anyone who knows the address can open it, and a crawler that ignores the file can read it. Private pages need a login or a password, not a robots.txt rule. The third mistake is forgetting the file exists: a staging copy of a site that blocks everything can be copied live with the blocking file still in place, and the live site never gets crawled.

The fourth mistake is a sitemap line that points nowhere: an address with a typo, a domain that has changed, or a sitemap that was never uploaded. The crawler follows the line, finds an error, and moves on. The fifth mistake is writing rules for a crawler by name and getting the name wrong, so the rules apply to no one. Keep it simple: User-agent: * covers every crawler, and it is what this tool writes. A JSON formatter can tidy the structured data that sits alongside the file.

How to use this robots.txt generator

First, type the paths to block, one per line, each starting with a slash. The default blocks /admin/ and /private/. Then type the full address of the sitemap, if the site has one — the default is https://example.com/sitemap.xml. Then pick the mode: custom rules to block the listed paths, or allow all to open everything.

The file below updates live as you type, and the results box shows the rule count, the mode, and whether the sitemap line is included. Check the count matches the paths you typed: if it does not, a line is blank or the mode is allow all, which ignores the paths.

Finally, copy the whole file and save it as robots.txt, then upload it to the root of your site, so it is reachable at yourdomain.com/robots.txt. Test it by opening that address in a browser: it should show the file, not an error. Then check it in the search engine's webmaster tools, which will report any line it cannot understand. Your paths never leave your device: the whole file is built in your browser. A word counter can check the length of any page text you are about to protect.

Frequently Asked Questions

No. Robots.txt only asks well-behaved crawlers not to visit a path. Anyone who knows the address can still open the page directly, and a crawler that ignores the file can still read it. Private pages need a login or a password, not a robots.txt rule. The file keeps pages out of search results; it does not make them secret.

Upload it to the root of your site, so it is reachable at yourdomain.com/robots.txt. The file must be named exactly robots.txt and sit at the top level, not inside a folder. After uploading, open the address in a browser to check it shows the file, then verify it in the search engine's webmaster tools.

That single line blocks the entire site from all crawlers, and the site will gradually disappear from search results. It is the most dangerous line in the file, and it is usually written by accident when a staging copy goes live. Read every Disallow line twice before uploading, and check the live file in webmaster tools right after.

Yes, they do different jobs. Robots.txt says which paths crawlers may not visit, and the Sitemap line inside it points at the sitemap, which lists the pages they should visit. A site with both files is found faster than a site with either one alone, because the crawler learns the rules and the page list on the same visit.

More free tools

More calculators and utilities from Sortrun — free, no sign-up.