Early-stage tech startups often need to manage search engine visibility during development or launch phases. This article explains the core components of a robots.txt file, including user-agent identification, allow/disallow rules, and sitemap directives, ensuring clean and effective crawler guidance.

Setting Up Basic Crawler Rules for Startup Sites

This is a hypothetical scenario: a two-person startup building a scheduling tool has a test server and a public marketing site, and the team is drafting its first robots.txt. The lead engineer jots three candidate rule names in a notebook—Test blocking, Sitemap pointer, and Crawl delay—then writes the actual file.

The draft begins with a user-agent line naming all crawlers, followed by a disallow rule pointing at the test path, so staging pages stay out of results while the marketing pages remain open. A second block names one specific crawler and repeats the same disallowed path, because the team wants that crawler to see only the public site. A sitemap line, written as a full address with the protocol, host, and the path sitemap.xml, points crawlers to the launch pages. The engineer considers adding a crawl delay for one aggressive crawler, then drops it, reasoning that the startup cannot verify how each engine treats the value and would rather keep the file short.

As a second example, a small team building a documentation site writes two fictional records into its launch checklist table. The first record lists the test host under a Blocked column with the note "no public pages yet"; the second lists the marketing host under an Allowed column with the note "index after launch." Each record includes a field for the rule owner, a date, and a link to the page where the rule lives, written as protocol plus host plus path. The rows are grouped by host so anyone editing the file later sees at a glance which site each rule governs. These are the author's own made-up examples, not records of a real launch.

The startup's choice between the two approaches comes down to scope: one shared file with a fully written sitemap address is simpler to maintain while the team is small, so that is the option the engineer picks. The checklist table is kept alongside it so the rules stay visible to whoever ships the next change.

Understanding User-Agent Fields and Rule Groups

For Google crawlers, a robots.txt line consists of a field, a colon and a value. Field names are case-insensitive, while values are case-sensitive; leading and trailing spaces are ignored, and text after a hash character is treated as a comment. Google supports user-agent, allow, disallow and sitemap, and does not support crawl-delay or other fields.1

Rules are organized into groups. A user-agent line identifies which crawlers a rule applies to, and repeating user-agent lines groups rules for several agents: the page's example shows one group for agent a, one for b, one shared by e and f, and one for h. The user-agent field name and its value are both case-insensitive.1

You can return to the notebook entry named Test blocking and expand it into a small group: one user-agent line for a named crawler, followed by the paths that crawler should avoid. A second group for all crawlers can then hold only the paths every crawler should skip. Check that no path appears in both an allow and a disallow line within the same group, since that overlap is the usual source of confusion.

For the Sitemap pointer entry, you might keep it outside any group and write the address once, so every crawler reads the same location. If the notebook also lists Crawl delay, consider whether that entry belongs in this file at all or in your own launch notes; either choice is defensible, but recording the reason makes the file easier to revisit.

As a demonstration, a draft might read: user-agent for a named crawler, disallow /staging, then user-agent for all crawlers, disallow /private. Renaming the first notebook entry from Test blocking to Staging exclusions would make the finished file match its purpose.

Applying Allow and Disallow Path Directives

The allow and disallow fields are the rules that state which URL paths may or may not be crawled. Google's documentation gives the form rule: path, with the value written as a path relative to the site root that hosts the robots.txt file. That path must begin with a slash for the root directory and is case-sensitive, so capitalization matters in the value.1

The documented example illustrates the split: user-agent * with disallow /includes/ keeps all crawlers out of that directory, while user-agent Googlebot with allow /includes/ lets that crawler reach it. The user-agent line determines which rules apply to which crawler, and the field names themselves are case-insensitive.1

Where an allow and a disallow rule conflict, Google's documentation says the least restrictive rule is used, and the more specific rule is chosen based on rule path length. A disallow rule blocks crawling, but Google notes it may still index the URL without a snippet.1

For the notebook entry named Test blocking, the two founders can now decide which paths belong in the draft. One might write the staging path as “/staging” and the internal preview area as “/preview”, placing each on its own Disallow line under the same user-agent group. Alternatively, a broader “/staging” rule can stand alone if the preview area sits beneath it. Consider which of these two shapes makes the file easier to reread a month later, when the team may no longer remember what each path covers.

A simple check you can apply to any candidate path: write down the first folder segment on one line and the more specific subpath on the next, then compare. If the broader entry already covers the narrower one, the narrower line may be redundant. If it does not, keep both and note beside each why it earns a separate line.

Allow rules are worth reserving for cases where a parent path is blocked but one child should remain reachable. You might draft a Disallow for a whole section and an Allow for a single public page inside it, then read the pair aloud to confirm the intent survives. Keep whichever pair you can explain in one sentence.

Referencing Sitemaps Within Robots.txt

The sitemap field in robots.txt takes a full URL pointing to a sitemap or sitemap index file. That URL must be fully qualified, including protocol and host, and does not need URL encoding. It does not have to sit on the same host as the robots.txt file, and multiple sitemap fields can be listed with no limit on how many.1

The sitemap field does not depend on any particular user agent; all crawlers can follow it as long as it is not disallowed. Note that crawlers ignore sitemap lines when processing group rules, so a sitemap entry placed between user-agent lines does not join those groups.1

For the notebook entry named Sitemap pointer, you can write one line outside any user-agent group that names the sitemap location, then read it back as a test: does the address point to the public marketing site, not the test host? In the hypothetical two-person team, the draft might pair a sitemap line for the marketing site with the existing test-blocking group, leaving the test host unlisted. You might compare two candidate lines side by side — one with the full public address, one with a missing path segment — and keep the complete one because a crawler reading a partial address may fetch nothing useful. If the team later adds a second public area, consider whether one sitemap line still covers it or whether a second line is clearer for your own review. As a filled example, a checklist row could read: entry name, Sitemap pointer; candidate value, public marketing site address; reason kept, matches the launching site pages.

Managing File Size and Encoding Constraints

The robots.txt file must be plain text encoded in UTF-8, with lines separated by CR, CR/LF, or LF, according to Google's documentation. Google ignores invalid lines, including a Unicode byte order mark at the start of the file, and uses only valid lines. If a file's character encoding is not UTF-8, Google may ignore characters outside the UTF-8 range, which could make rules invalid.1

Google enforces a robots.txt size limit of 500 KiB and ignores content beyond that limit. The documentation suggests reducing file size by consolidating rules that would otherwise make the file too large, for example by placing excluded content in a separate directory.1

For the notebook entry named Test blocking, you can now turn the rule names into a short plain-text draft and check how the file will be read. When saving that draft, keep it as a purely ASCII text file and avoid curly quotes, long dashes, or accented characters in comments and path names. If you have a path containing a non-ASCII word, you might write the percent-encoded form instead, which keeps the line readable by crawlers.

Before uploading, you could compare the draft's byte size against your own comfort limit. One founder can open the file and note its size in bytes, then count the lines; a single sitemap pointer line and a few user-agent groups usually stay small, so the check is mainly to catch accidental copies of long blocked paths.

For the Sitemap pointer entry, you can write the address once and confirm the saved file still contains only plain characters. If a line looks garbled after pasting between editors, that is a cue to rewrite it rather than keep both versions.

Reviewing Syntax Validity and Common Errors

For the notebook entry named Test blocking, you can now reread the saved file line by line as a stranger would. Start with the user-agent line: does the crawler name sit immediately after the colon, with the rule lines below it and no blank line splitting the group? If a path was intended for one named crawler but the disallow ended up under the wildcard group, move it back or accept the wider scope deliberately.

A common slip is placing the Sitemap pointer inside a group. You might copy the line and paste it below a blank line so it stands alone, since its position should not depend on which crawler last appeared. Another is a stray allow direct record that silently reopens a path the disallow closed; reading both lines together in order helps you catch that conflict.

For repeated rules, check for duplicates that disagree, such as one line naming a path with a trailing slash and another without. Note which spelling appears in the draft and delete the unused variant. If the typed and read-back draft differ by a trailing comment, keep the comment only if it stays on its own line beginning with the hash character.

Before saving, you could add two fields to the notebook table under Test blocking: “Path spelling checked” and “Group boundary checked.” Fill each with yes or revise, then make the revision your next action.

Frequently asked questions

How can the founders write the staging and internal preview paths for the Test blocking entry?

For the notebook entry named Test blocking, the two founders can now decide which paths belong in the draft. One might write the staging path as “/staging” and the internal preview area as “/preview”, placing each on its own Disallow line under the same user-agent group.

How can I check whether a narrower candidate path is redundant against a broader entry?

A simple check you can apply to any candidate path: write down the first folder segment on one line and the more specific subpath on the next, then compare. If the broader entry already covers the narrower one, the narrower line may be redundant.

How should I handle repeated rules that name the same path with and without a trailing slash?

For repeated rules, check for duplicates that disagree, such as one line naming a path with a trailing slash and another without. Note which spelling appears in the draft and delete the unused variant.