Robots.txt Guard

Catches robots.txt rules that would quietly de-index a site, like Disallow: / in production or blocked CSS and JS.

StopsSite de-indexed by robots.txt

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/robots-txt-guard.json

The files land in your project. They're yours to edit.

Usage

robots-txt-guard-usage.tsx
import { RobotsTxtGuard } from "@/components/ui/robots-txt-guard"

return <RobotsTxtGuard production siteUrl="https://acme.com" defaultValue={copiedFromStaging} />

What it catches

  • Disallow: / and staging leftovers in a production file
  • Rules that block CSS and JS asset paths used for rendering
  • Relative or wrong-host Sitemap lines
  • Directive typos and missing colons
  • Fields Google doesn't support (crawl-delay, noindex)
  • Which line decides a crawl for a given URL and user agent

Props

RobotsTxtGuard props
PropTypeDefault
value

Controlled robots.txt text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the new text on every edit or fix.

(value: string) => void—
production

The file is about to serve production, so Disallow: / and staging leftovers are flagged.

booleanfalse
siteUrl

The live origin (https://acme.com). Enables sitemap host checks and one-tap sitemap fixes.

string—
assetPaths

Extra CSS/JS paths that must stay crawlable, e.g. "/build/app.css".

string[]—
agents

Crawlers offered in the URL tester.

string[]["Googlebot", "Googlebot-Image", "Bingbot", "GPTBot"]
label

Visible label; shorthand for `messages.label`.

string—
messages

Every visible string. `{line}`, `{detail}`, `{fix}`, `{rule}`, `{agent}`, `{path}`, `{host}`, `{count}` are filled in.

Partial<RobotsTxtGuardMessages>—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible <label> on the textarea; aria-invalid on errors and a role=status issue count
  • Each issue has a button to select its line, with an aria-label
  • After a fix, focus moves to the next fix or back to the textarea
  • URL tester inputs have labels; results use icon plus text

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Models Google's robots.txt rules; other crawlers interpret files differently
  • robots.txt controls crawling, not indexing; blocked URLs can still be indexed from links
  • Asset checks use the paths you pass

Rules

Rules last verified:

Confirmed: Google supports user-agent, allow, disallow and sitemap (crawl-delay isn't supported) and uses the most specific matching user-agent group. Check the source for changes. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

Site de-indexed by robots.txt

Also known as

robots.txt · seo · disallow · sitemap · googlebot · crawl · indexing · search console

Field type

Dependencies

Pairs well with