Quick answer
To stop crawlers fetching a folder, put a Disallow rule for it in the User-agent: * group of your site's robots.txt, and keep the slash at both ends of the path: Disallow: /drafts/. Then test a few URLs before you upload the file.
That rule stops well-behaved crawlers from fetching the pages. It doesn't keep them out of Google. Google says robots.txt "is not a mechanism for keeping a web page out of Google", and a blocked URL "can still appear in search results, but the search result won't have a description" (Google Search Central: Introduction to robots.txt).
Pick the control that matches what you want:
- Stop crawlers fetching it: use
Disallowin robots.txt. This suits URLs with nothing worth crawling, such as internal search results. - Keep it out of search results: add a
noindexrule to each page and leave the pages crawlable. Google has to fetch a page to see the rule (Google: Block Search indexing with noindex). - Keep people out: put the folder behind a login. robots.txt is a public request, not a lock.
The example site used in this guide
The test uses a fictional site at www.example.com with two folders that crawlers don't need to fetch:
/drafts/: unfinished articles./internal-search/: the site's own search results pages.
Build the file
In FreeToolsKit's Robots.txt Generator & Validator, on the Generate robots.txt tab:
- Under 1. Website (optional), type
https://www.example.comin Website origin. The tool shows the address to publish the file at, directly under the site's root as/robots.txt. The origin isn't written into the file. - Under 2. Crawler groups, Group 1 already has the user-agent
*, which means every crawler without its own group. Leave the rule type as Disallow and type/drafts/as the path. - Choose Add rule, keep Disallow and type
/internal-search/. - Under 3. Sitemaps (optional), choose Add sitemap and type the sitemap's full address, starting with
https://. Sitemap lines apply to the whole file, not to one group. - Under 4. Your robots.txt, check the status line. It read "Ready — 107 bytes, UTF-8."
- Choose Copy robots.txt ("robots.txt copied.") or Download robots.txt ("robots.txt downloaded. Upload it to your site's root folder.").
The downloaded file was named robots.txt, 107 bytes, and matched the copied text exactly. It has five lines:
User-agent: *Disallow: /drafts/Disallow: /internal-search/- a blank line
Sitemap:followed by the full sitemap address
Pasted into the Validate existing file tab, it gave "No syntax errors or warnings found locally."
Test the folder rule before you upload it
On the Test a URL tab, keep Generated robots.txt, leave Crawler (user-agent token) on Googlebot, and type each path into URL or path to test. These were the verdicts:
/drafts/and/drafts/spring-launch.html: Disallowed. The tool named the deciding rule: "Disallow: /drafts/" on line 2 "is the most specific matching rule in the * group"./drafts, without the final slash: Allowed. "No rule in the * group (User-agent on line 1) matches /drafts, so crawling is allowed."- Look-alike paths,
/drafts-archive/2025-review.htmland/draftsman.html: Allowed, because neither starts with/drafts/. /Drafts/spring-launch.html, with a capital D: Allowed. Paths are case-sensitive./internal-search/?q=boots: Disallowed by line 3. The query string counts as part of the path./internal-search?q=boots: Allowed. If your search form sends visitors to a URL like this, the folder rule misses it, so test the URLs your site actually produces.- The same draft on
example.com, without www: Cannot be determined. The tool explained that the rules were for the www origin and "Each protocol, hostname and port has its own robots.txt, so this file doesn't decide that URL."
The results were the same with Any crawler without its own group (*), because the file has only the * group.
These verdicts follow the published rules. Google's own example says /fish/ "Matches anything in the /fish/ folder" but not /fish or /fish.html. A file on www.example.com doesn't apply to example.com (Google: How Google interprets the robots.txt specification). Google also says a folder path "must end with the / mark", and that rules are case-sensitive (Google: Create and submit a robots.txt file).
What a missing slash does
The same test with Disallow: /drafts, without the final slash, pasted on its own, went the other way. /drafts, /drafts-archive/2025-review.html and /draftsman.html were all Disallowed, because a rule matches any path that starts with it.
The validator reported "No syntax errors or warnings found locally." for that file. A missing slash is valid syntax, so only a URL test shows what it catches.
When an Allow and a Disallow rule both match
To leave one subfolder crawlable, such as a press kit inside /drafts/, add an Allow rule for it. The test used this file, with the Allow line first:
User-agent: *Allow: /drafts/press-kit/Disallow: /drafts/
Results with Pasted robots.txt selected:
/drafts/press-kit/logo.png: Allowed. The tool said the Allow rule "is longer than "Disallow: /drafts/" (line 3), so it wins regardless of order in the file."/drafts/spring-launch.html: Disallowed byDisallow: /drafts/.
With the two rules in the opposite order, Disallow first, both results were the same: the longest matching rule wins, not the first. When an Allow and a Disallow rule had the same path, /drafts/, the URL was Allowed and the validator added a note: "Allow and Disallow both use "/drafts/" (lines 2 and 3); Allow wins the tie."
Both results match the standard. RFC 9309 says "The most specific match found MUST be used", and if an allow and a disallow rule are equivalent, "the 'allow' rule SHOULD be used" (RFC 9309: Robots Exclusion Protocol). Google says it uses "the most specific rule based on the length of the rule path", and the least restrictive rule when rules conflict (Google: How Google interprets the robots.txt specification).
Why Disallow doesn't keep a page out of Google
A disallowed URL can still be indexed when other pages link to it. Google can't read the blocked content, so "it may still index the URL and show it in search results without a snippet" (Google: How Google interprets the robots.txt specification).
To keep a page out of results, Google's instruction is to "use noindex and allow Google to crawl the URL" (Google Search technical requirements). The rule goes on the page as a robots meta tag, or in an X-Robots-Tag HTTP header, which also works for files such as PDFs. Blocking the page in robots.txt defeats it: "the crawler will never see the noindex rule, and the page can still appear in search results" (Google: Block Search indexing with noindex).
A noindex line in robots.txt doesn't work
Some old advice puts Noindex: in robots.txt. Google says "Specifying the noindex rule in the robots.txt file is not supported by Google" (Google: Block Search indexing with noindex).
The validator flags it. This file was pasted into Validate existing file:
User-agent: *Disallow: /internal-search/Noindex: /drafts/
The status read "No syntax errors. 1 warning and 0 notes to review." The warning, labelled Crawler support and Line 3, said: "Google doesn't support noindex in robots.txt, so this line won't keep pages out of search results. Use a robots meta tag or X-Robots-Tag header on a crawlable page instead."
The tester then gave Allowed for /drafts/spring-launch.html. The Noindex: line isn't a rule, so it didn't even stop crawling.
If pages from the folder are already in Google
- Leave the folder crawlable. Don't add a
Disallowrule for it, or remove the one you added. - Add noindex to each page. Use a robots meta tag, or the
X-Robots-Tagheader for non-HTML files. The Google SERP Snippet & Meta Tag Preview can generate the meta tag. - Wait for a recrawl. Google says "it may take months for Googlebot to revisit a page", and you can ask for a recrawl with the URL Inspection tool (Google: Block Search indexing with noindex).
- For something urgent, also use Google's Removals tool. Google says it removes a page from its results "within a day", but "Requests made in the Removals tool last for about 6 months". The same page says: "Don't use robots.txt as a way to block your page" (Google Search Central: Remove your site info from Google).
Keep the noindexed pages crawlable after they drop out. If you block them later, Google can no longer see the rule.
Private folders need a login, not robots.txt
robots.txt is public, and following it is voluntary. RFC 9309 says the rules "are not a form of access authorization", and that listing paths in the file "makes the paths discoverable" (RFC 9309: Robots Exclusion Protocol). Google adds that "it's up to the crawler to obey them" (Google Search Central: Introduction to robots.txt).
For anything private, such as client files or a staging copy of the site, use a password or login, and leave its path out of robots.txt.
Before you upload the file
- Folder paths: every folder rule starts and ends with
/, and its letter case matches your real URLs. - URL tests: you've tested a URL inside each folder, the folder name without its final slash, a look-alike path and the URLs your site generates, such as search results.
- Page resources: you aren't blocking folders of CSS, JavaScript or images that your pages need. Google says to block resource files only if pages "won't be significantly affected by the loss" (Google Search Central: Introduction to robots.txt).
- Named crawler groups: if you add a group for a specific crawler, for example an AI crawler, repeat your folder rules in it. Google uses only "the group with the most specific user agent that matches", and other groups are ignored (Google: How Google interprets the robots.txt specification). Whether to allow or block any particular AI crawler is a separate policy decision.
- Every host: the file is at the root of each host you serve, so the www and non-www versions each answer
/robots.txt. - After upload: open
/robots.txton your domain in a private window to check it loads. Google "generally caches the contents of robots.txt file for up to 24 hours", so changes aren't picked up at once (Google: How Google interprets the robots.txt specification).
The tool's results are a local simulation of these rules. It never fetches your site, so it can't see redirects, server errors or a different live file.

