robots.txt JavaScript API

Everything the robots.txt extension adds to pb_hooks and page code, generated from the TypeScript declarations it ships (your app's types.d.ts has the same, so your editor knows them). For how to use it, see its docs; for Go, the Go API.

$robotsTxt

The app's /robots.txt (ext/robots-txt). Rules from every pb_hooks file and extension end up in one file. Anyone can read it: it keeps crawlers out, it doesn't protect anything.

$robotsTxt.add()

$robotsTxt.add(rule: { disallow?: string; allow?: string; userAgent?: string; sitemap?: string }): void

Adds a line: disallow or allow a path prefix for userAgent (default every crawler, *), or an extra sitemap URL (absolute, or a path on this app).

Parameter Type
rule { disallow?: string; allow?: string; userAgent?: string; sitemap?: string }

$robotsTxt.private()

$robotsTxt.private(prefix: string): void

Makes a path prefix private: a Disallow line, left out of the sitemap and llms.txt, and every response under it sent with X-Robots-Tag: noindex.

Parameter Type
prefix string