Standard 10 of 30 · Transport, Crawling & Discovery
robots.txt
The root-hosted plain-text file (/robots.txt) implementing the Robots Exclusion Protocol for a specific host and port.
Reviewed
Engineering Purpose
Provides an immediate crawler policy declaration and links crawlers to the canonical XML sitemap.
Browser & Search Relevance
Prevents accidental crawling of internal API routes while ensuring public marketing and knowledge routes remain open.
Correct Implementation Patterns
- Keep /robots.txt valid UTF-8 text returning HTTP 200 with explicit Sitemap pointer
export default function robots(): MetadataRoute.Robots {
return { rules: [{ userAgent: "*", allow: "/", disallow: ["/api/"] }], sitemap: "..." };
}Next.js App Router Considerations
- Use app/robots.ts rather than hardcoding stale domain URLs in static public/robots.txt.
Common Errors
- Leaving Disallow: / active after staging-to-production deployment
Testing Methods
- Direct GET /robots.txt check after every production build