robots.txt

Version 0.0.1 · Owners: @benallfree

Walkthrough for app owners: robots.txt. This page is the technical reference.

Crawlers read /robots.txt before anything else to learn what they may fetch. This extension answers it when your app has no robots.txt of its own. Out of the box it closes only the dashboard:

User-agent: *
Content-Signal: search=yes, ai-input=yes, ai-train=no
Disallow: /_/
Disallow: /mcp

Sitemap: https://notes.example.com/sitemap.xml

/mcp comes from MCP, the Sitemap line from sitemap.xml when the app has pages to list. Everything else is open to every crawler, AI training crawlers included, until you say otherwise.

The Content-Signal line (contentsignals.org) says what crawlers may do with what they fetch: search (a search index), ai-input (an AI answer built from the page) and ai-train (training a model). Out of the box every crawler may index pages and use them in AI answers, and is asked not to train on them: a request, like the rest of the file, and it doesn't block anyone. search is always no while the app is kept out of search, and ai-train while AI training crawlers are blocked. Set them in Settings or pocketone.yaml (Configure).

  • Your own file always wins. Put robots.txt in pb_public or pb_pages (or serve the path from a route) and that answers instead, whole.
  • Private paths. A prefix marked private gets a Disallow line, is left out of the sitemap and llms.txt, and every response under it carries X-Robots-Tag: noindex, nofollow, which keeps it out of search even when it's linked from elsewhere.
  • Staging and dev apps stay out of search. In dev mode (--dev), or with Keep this app out of search results on, every response says noindex and the sitemap is empty. robots.txt itself stays open, so crawlers can see the header and drop pages they already have.
  • It's public, and it's a request. Anyone can read it, and only polite crawlers follow it. It protects nothing: use API rules for that.

It provides the robotstxt/v1 contract.

Install · Configure · Use · Integrations · Example

Install

It's built into pocketone and on in every app: a member of the standard set, so a Go build made with standard.New() has it too. On its own:

extkit.Setup(app, []extkit.Extension{robotstxt.New()}, nil, nil)

The module is pocketone.dev/ext/robots-txt.

Configure

In the app's dashboard (/_/), click Settings, then Extensions in the sidebar; the robots.txt section on that page has these fields:

Field What it does
Keep this app out of search results Every response says X-Robots-Tag: noindex, nofollow and the sitemap is empty. For staging and preview apps. Dev mode always does this.
Block AI training crawlers Adds a group closing the app to crawlers that collect pages to train AI models: GPTBot, ClaudeBot, Google-Extended, Applebot-Extended, CCBot, Bytespider, meta-externalagent. Assistants fetching a page because someone asked are still let in.
Private paths One prefix per line (/account): Disallow, left out of the sitemap and llms.txt, noindex.
Extra disallow One prefix per line crawlers shouldn't fetch. Unlike private paths, a page there may still show up in search if it's linked from elsewhere.
Content signals: user agents The crawlers the Content-Signal line is for, one per line. Default *. Other agents get a group of their own, with every crawler's rules copied in. Overrides pocketone.yaml.
search, ai-input, ai-train Ticked is yes, unticked no. Defaults: search and ai-input ticked, ai-train not. Each overrides pocketone.yaml.

They're kept in the key-value store as _robots-txt/settings, so they ride along in backups. When the app serves its own robots.txt, the form says so: the fields then only change the noindex header and what the sitemap and llms.txt leave out.

Content signals in pocketone.yaml

The Content-Signal fields can also be set in pocketone.yaml. For each field, the value saved in Settings is used if there is one, else the file's, else the built-in default. The form opens with the values in use and saves only the fields you change, so a field you didn't change keeps following the file:

robots-txt:
  content_signal:
    user_agents: ["*"]
    search: true
    ai_input: true
    ai_train: false

Each key is optional; an unset one keeps its default (the values shown). On a multisite host the same keys go in pocker's isolate_config or an instance's extensions.robots-txt, which replace the host file's values for that instance. Values saved in the instance's own Settings are used over all of these.

Turn it off

To turn the extension off on a single app, in pocketone.yaml:

robots-txt:
  enabled: false

On a multisite host that doesn't reach the instances: an instance sets extensions.robots-txt.enabled: false (or pocker's isolate_config does, for every instance).

pocketone.yaml reference

robots-txt:

The generated /robots.txt: on or off, and its Content-Signal line (user agents, search, ai-input, ai-train). Values saved in Settings → Extensions → robots.txt are used instead.

Key Type Default Description
enabled bool On unless false.
content_signal.user_agents list of string The User-agent lines the Content-Signal line is for. Default ["*"], every crawler.
content_signal.search bool May build a search index and show results. Default true; no while the app is kept out of search.
content_signal.ai_input bool May use a page in an AI answer (RAG, grounding, AI search). Default true.
content_signal.ai_train bool May train or fine-tune AI models. Default false; no while AI training crawlers are blocked.

Use

Open https://<your app>/robots.txt.

Add rules from pb_hooks

// pb_hooks/robots.pb.js
$robotsTxt.add({ disallow: "/search" })
$robotsTxt.add({ userAgent: "Bingbot", allow: "/api/files/" })
$robotsTxt.add({ sitemap: "/feeds/sitemap.xml" }) // a path becomes https://<your app>/feeds/sitemap.xml
$robotsTxt.private("/account")

add takes one of disallow, allow or sitemap, and an optional userAgent (default *); unknown keys throw. private(prefix) marks a prefix private. A hooks reload starts over with what your files add again, so rules never pile up.

Pages adds its own: every prefix in pb_pages/+config.js's private: [...] is private.

What the file looks like

Rules are grouped by user agent, * first, then the others in the order first added, then the content signal user agents other than *, then the AI training group, then every Sitemap line. The Content-Signal line comes right after its group's User-agent lines. A group with nothing closed says Disallow: (empty), which RFC 9309 reads as "everything is open". Duplicate lines are dropped.

It's served as text/plain with a five-minute Cache-Control, for GET and HEAD only.

Commands and APIs

Generated from the pocketone binary and the contracts this extension provides.

JavaScript API

What it adds to pb_hooks and page code: robots.txt JavaScript API.

Integrations

Works with

Extension How they fit
sitemap.xml Adds the Sitemap: line when there's a sitemap to read. The sitemap leaves out private paths, and is empty when the app isn't indexable.
llms.txt Pages' ## Pages section leaves out private paths.
Pages +config.js private: ["/account"] makes those prefixes private. A pb_pages/robots.txt answers instead of the generated file: this extension's middleware runs just inside Pages' and only fills a 404.
MCP Adds Disallow: /mcp.
Settings Shows the form (settings/v1).
Key-Value Store Keeps the settings (kv/v1, the private name _robots-txt/settings).
Multisite Every instance answers its own /robots.txt with its own rules and URLs.

Add a rule from Go

robotstxtv1.Add(app, robotstxtv1.Rule{Disallow: "/drafts", Source: Name})
robotstxtv1.Private(app, "/account", Name)

Declare WorksWith: extkit.IDs("robotstxt/v1"). Rules that change at run time come from robotstxtv1.AddFunc(app, func(core.App) []robotstxtv1.Rule), called on every read.

Replace it

Another extension can provide robotstxt/v1 and serve the file its own way from robotstxtv1.Rules(app). This one then steps aside: no file, no noindex header.

Example

The example app answers /robots.txt with the default rules plus one of its own, and marks /account private.

// Command example is a PocketBase app with a generated /robots.txt: the dashboard closed, plus a rule and a private
// path the app adds itself. Run `go run . serve` and open http://127.0.0.1:8090/robots.txt.
package main

import (
	"log"

	"ganigeorgiev.com/pocketbase/pocketbase"

	robotstxtv1 "pocketone.dev/ext/contracts/robotstxt/v1"
	"pocketone.dev/ext/extkit"
	robotstxt "pocketone.dev/ext/robots-txt"
)

func main() {
	app := pocketbase.New()
	if _, err := extkit.Setup(app, []extkit.Extension{robotstxt.New()}, nil, nil); err != nil {
		log.Fatal(err)
	}
	robotstxtv1.Add(app, robotstxtv1.Rule{Disallow: "/search", Source: "example"})
	robotstxtv1.Private(app, "/account", "example")
	if err := app.Start(); err != nil {
		log.Fatal(err)
	}
}

Root path

/robots.txt is fixed by RFC 9309, so it sits at the root beside /llms.txt and /sitemap.xml. Like them, an app replaces it with a file of its own: the extension answers only what the app left as a 404.

License

MIT