Write a crawlable robots.txt

robots.txt controls crawling, not indexing. Serve one file per host at the root with a 200 status and a sitemap reference, allow CSS and JavaScript so rendering matches users, and block only infinite or private URL spaces. A single Disallow: / line can remove the entire site from search.

mediumIn codeimpact effort

Why this matters

One root file, CSS and JS allowed, sitemap referenced, no accidental site-wide block.

Get the full breakdown

The extended brief explains when this works, when it does not, and the trade-offs. Join the waitlist and it unlocks for every tip when sign-in opens; MCP access is the paid part.

Join the waitlist

Before you start

  • Control over the domain root

How to apply it

  1. Serve one valid file at the root

    Return robots.txt from https://your-host/robots.txt with status 200 and content-type text/plain. Do not redirect it and do not serve a cached HTML error page.

    Check: curl -sI your production domain/robots.txt returns 200 and content-type text/plain.

  2. Allow rendering resources and reference the sitemap

    Do not disallow CSS, JavaScript or image files needed to render pages. Add a Sitemap line with an absolute HTTPS URL near the top of the file.

    Check: robots.txt contains a Sitemap: line whose URL returns 200.

  3. Block only infinite or private spaces General best practice

    Disallow crawl paths that generate unlimited URLs, such as internal search or sort parameters. Never ship Disallow: / outside a staging environment.

    Check: grep -c '^Disallow: /$' robots.txt returns 0 in production.

Get the prompt for your agent

A ready-to-paste prompt for your agent that implements this tip and verifies the result in your repo.

Join the waitlist

Source: seo-mcp playbook · curated entry · report an error

Official references

Framework notes

nextjs-app

Add `app/robots.ts` exporting a `MetadataRoute.Robots` object with `rules` and `sitemap`; it generates `/robots.txt` at build time.

astro

Place `public/robots.txt` in the static assets directory, or generate it from an endpoint and reference `@astrojs/sitemap` output.

wordpress

WordPress serves a virtual robots.txt. Filter it with `robots_txt`, or disable the virtual file and ship a physical one; SEO plugins also expose this screen.

Let your agent apply this + 161 more tips.

Pre-order — $19