Design and consulting agencies often need to control which parts of a client's website are accessible to search engine crawlers. This article explains the basic syntax, placement, and testing procedures for creating a clean robots.txt file that aligns with standard crawler expectations.

Understanding the Role of Robots.txt in Site Management

This is a hypothetical example of how a small agency might draft a robots file, not a record of a real client engagement. Picture an independent web designer preparing a new site for a workshop client and a small legal consultancy. The designer has no central content system and must decide, page by page, which paths should be off limits to crawlers.

The draft begins with a short comment block naming the project and date. Then come three groups of rules. The first, labelled “All general crawlers,” contains a user-agent line set to a wildcard and a disallow line covering the internal search path. The second, “Staging and preview,” disallows two folders: one for draft client pages and one for a temporary image library used during reviews. The third, “Sitemap pointer,” lists a single sitemap location to help crawlers find the public pages that are meant to be indexed.

The designer also writes two title candidates in the margin, purely to organise the notes: “Public Pages — Allow by Default” and “Private Paths — Block by Folders.” For the first candidate, the working rule is to leave ordinary service pages open and block only the internal search and account areas. For the second, the working rule is to block every URL under a named staging folder rather than listing individual files. The designer chooses the folder-level approach for the staging area because new draft pages will keep appearing there, and blocking the parent path covers them without edits.

The draft ends with a note reminding the reader that crawler behaviour varies, that a robots file does not secure a page, and that the file must be checked after launch. These are the author’s own planning notes, not published guidance and not the result of any test.

Basic Syntax and Field Definitions

Google’s documentation describes a valid robots.txt line as a field, a colon, and a value. Field names are case-insensitive, spaces are optional but recommended for readability, and spaces at the start and end of a line are ignored. A hash character starts a comment, and everything after it is ignored.1

The documented fields are user-agent, which identifies the crawlers a rule applies to; allow and disallow, which give crawlable and non-crawlable paths; and sitemap, which gives the full URL of a sitemap. Google’s documentation says it does not support other fields such as crawl-delay.1

Allow and disallow values are relative to the root of the site hosting the file and must start with a slash. The field names are case-insensitive, but the path values are case-sensitive. Rules without a path are ignored.1

You can take your own working copy of the robots file and, beside each line, write a plain-language note about what that line does before you decide whether to keep it. Start with the user-agent line at the top of a group: note which named crawler the group addresses, or whether it addresses all of them. Then look at each disallow line below it and jot down the path it names in words a client would recognise. For a workshop client, you might mark a paths line as “booking drafts, not public yet”; for a legal consultancy, “consultation notes, keep out of results.”

A small comparison exercise can make the choices clearer without any outside action. Write two candidate versions of the same group, one that blocks a folder by its directory prefix and one that blocks a single named file, then read both as if you were the crawler. Which one matches the material you actually want excluded? You can choose the narrower version when only one document is private, and keep the broader one only if the whole folder is genuinely off limits.

If you plan a crawl-delay line, leave a space in your notes to record the reasoning and who asked for it, so a later editor does not inherit a number without context. Treat every line as a decision you can revisit, and mark any line you are unsure about rather than deleting it silently.

File Placement and Encoding Requirements

The file must be named robots.txt and placed at the root directory of the host it governs. For example, to control crawling for a specific domain, the file belongs directly under that domain's root path, never inside subdirectories. Each host or port requires its own separate file; rules in one location do not apply to subdomains or different protocols. The document must use UTF-8 encoding, which includes ASCII. Avoid word processors that may insert proprietary formats or unexpected characters like curly quotes, as these can cause parsing errors. If system prompts appear during saving, explicitly select UTF-8 to ensure crawler compatibility.2

Start with your own draft robots file and choose where you intend to keep it: the root of the site, in the same place you store a small sitemap or a maintenance note. You can write the filename in lowercase and record it in your project notes beside the path you plan to use, so a second editor does not create a variant with different capitalisation. If your workflow already includes a plain-text copy of the draft, you might add a one-line note stating the intended location and character set, then read the whole file once to check that quotation marks, slashes and line breaks look consistent.

Consider comparing the same short rule written twice in your notebook, once with a slash at the start of the path and once without, and writing a plain note beneath each about which directories you think it covers. This is only a hypothetical exercise; choose the version that matches your own intent and mark the other as rejected. For an archived announcement, you can use the same two fields in a small table: a location field reading “root of the site” and an encoding field reading “plain text,” then fill the same fields for a current entry and note how they differ. You might also leave a blank line between rule groups and note why you kept it, so the layout remains readable after future edits.

Grouping Rules by User-Agent

Google documents that rules for multiple user agents can be grouped by repeating the user-agent line. In its example, user-agent: e and user-agent: f followed by disallow: /g form one group, while user-agent: a with disallow: /c and user-agent: b with disallow: /d each form separate groups, and a standalone user-agent: h is its own group as well.1

For any given crawler, only one group is valid. Google's crawlers look for the group containing the most specific user agent matching the crawler, and other groups are ignored; the order of groups in the file does not matter. If multiple specific groups are declared for a user agent, their applicable rules are merged internally into one group, but a user-agent-specific group and the global group (*) are not merged.1

Take the three draft groups already labelled in your working copy and try one fresh pass through them with a different organising idea: group by crawler identity rather than by folder. You can keep the paths you have already chosen and simply rearrange which group owns them. A version worth considering puts every general crawler in the first group, one named crawler you actually care about in a second, and an explicitly unnamed group last, so a reader can see at a glance which rules apply where.

For the workshop client, you might write the second group as a named crawler set with only two paths, then add a short note beside it: "named crawler — same paths as general, different order." For the legal consultancy, your notes could instead record one path moved from the general group into the named group, with the reason written plainly: "kept out of general group because the page is unfinished."

Choose whichever arrangement you find easiest to explain later; neither is wrong. Before you settle, note two things you can verify yourself: whether any path now appears under two crawler groups, and whether the last group is intended to catch crawlers you have not named. Write those two answers beside the groups. If both answers leave you uncertain, you can consider merging the groups back into one until the page list is stable.

Common Mistakes and Limitations

A robots file is not a way to keep a page out of search results. Google's documentation states that if it blocks crawling, the URL may still appear in results without a description, and that other sites linking to the blocked page can lead to it being indexed anyway. Pages that must stay out of results call for another method, such as noindex or password protection.3

The documentation also notes that not every search engine supports robots rules, and that conforming crawlers may parse the syntax differently. Whether a command is followed is left to the crawler.3

The documentation further warns that blocked pages exclude embedded images, videos, PDFs and other non-HTML files from crawling unless other allowed pages reference them.3

Take one line from your own draft robots file, such as a folder you decided to block, and write a second version of that line with the reasoning reversed: what would change if you allowed it instead? This is a private writing exercise, not a file you need to deploy. The point is to see whether your original note still reads clearly when the choice flips, and to notice any path you blocked without being able to say why.

You might also revisit the comment block at the top of your working copy and check whether it still describes the draft you have now. If you added rules after the last edit, the comment may claim more certainty than the draft supports. Consider rewriting it as a dated note of intent, for example "draft for workshop client — private paths provisional," rather than a statement of policy. Choosing to leave the date off is also fine; just decide deliberately.

A useful limitation to record beside your draft: a robots file expresses a preference to crawlers, not a restriction on visitors, and the paths you list may still be reachable by other means. You can write that as a one-line caveat in your notes so a later reader does not treat the file as access control. That note costs little and prevents a common misreading.

Testing and Validation Steps

You can take your own draft and plan a small validation pass before anyone publishes it. Choose one dated working copy and mark each line you intend to keep, so the checks attach to something concrete rather than to a remembered version. If you keep a root draft and a parallel sitemap note, list both at the top; that makes a later edit easier to trace without turning the note into a formal record.

Next, consider writing three short examples in the margin, each labelled as a check. One might read: “Current entry — blocks private folder — rationale: client files not public.” Another: “Archived entry — same folder, older path spelling — rationale: keep with earlier draft.” A third could compare a wildcard group with a named-crawler group, with a note such as “named group repeats the same two paths — chosen because easier to explain.” These are placeholders for your own reasoning, not evidence that any crawler will behave a certain way.

For a hypothetical workshop client, you might record: “Latest draft — path blocked — reviewer: designer — next check: confirm path still matches the navigation.” For a legal consultancy draft, you could write: “Earlier saved version — same rule, different date — keep beside current copy.” The same fields work for a current and an archived item; only the date and the reason for keeping the older copy change.

You can also choose to record what you cannot confirm yourself, such as whether a path name has changed since the last draft. Mark such points as open questions beside the line, not as settled facts. A short note saying “check against site structure later” is more useful than a confident claim you have not tested.

Finally, revisit the comment block and the date on your working copy and decide whether to revise it before you share the draft. You might keep a second copy with the older comment intact, so a later reader can see what changed and why.

Frequently asked questions

How can I annotate my own working copy of the robots file line by line?

You can take your own working copy of the robots file and, beside each line, write a plain-language note about what that line does before you decide whether to keep it. Start with the user-agent line at the top of a group: note which named crawler the group addresses, or whether it addresses all of them.

How can I compare two candidate versions of the same rule group in my notes?

A small comparison exercise can make the choices clearer without any outside action. Write two candidate versions of the same group, one that blocks a folder by its directory prefix and one that blocks a single named file, then read both as if you were the crawler.

Where should I plan to keep my own draft robots file, and how should I record the filename?

Start with your own draft robots file and choose where you intend to keep it: the root of the site, in the same place you store a small sitemap or a maintenance note. You can write the filename in lowercase and record it in your project notes beside the path you plan to use, so a second editor does not create a variant with different capitalisation.