feat(metadata): support non-standard directives in robots.ts via other#93206
Merged
timneutkens merged 1 commit intocanaryfrom May 1, 2026
Merged
feat(metadata): support non-standard directives in robots.ts via other#93206timneutkens merged 1 commit intocanaryfrom
other#93206timneutkens merged 1 commit intocanaryfrom
Conversation
Adds an `other` field on each rule in `MetadataRoute.Robots` so users can declare non-standard robots.txt directives (e.g. Seznam `Request-Rate`, Yandex `Clean-param`) alongside the standard fields. Values are passed through verbatim and scoped to the rule's User-Agent block. Array values emit one line per entry. Fixes #89521
dia-loghmari
approved these changes
Apr 27, 2026
gnoff
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Adds an
otherfield to each rule inMetadataRoute.Robotssoapp/robots.tscan emit non-standard per-user-agent directives (e.g. SeznamRequest-Rate, YandexClean-param) alongside the standardallow/disallow/crawlDelayfields.emits:
Why?
The current
resolveRobotsserializer only writes the four standard rule fields and silently drops everything else, so users who need non-standard directives (common for Seznam, Yandex, and other crawlers) have to deleterobots.tsentirely and hand-maintain a staticrobots.txt, losing the type-safe, code-driven workflow.How?
packages/next/src/lib/metadata/types/metadata-interface.ts): factored a sharedRobotsRuleBasecontaining the existing optional fields plusother?: Record<string, string | number | Array<string | number>>.RobotsFile.rulesstill enforcesuserAgentas required on the array form.packages/next/src/build/webpack/loaders/metadata/resolve-route-data.ts): afterCrawl-delayand before the trailing blank line, walksrule.otherand emitsKey: valuelines preserving casing. Array values expand into repeated lines;null/undefinedentries are skipped. Keeps non-standard directives scoped to theirUser-Agentblock.resolveRobotscases covering theRequest-Ratereproduction and an array-valuedClean-param, plus null/undefined handling. Existing snapshots are unchanged, proving the change is additive.docs/01-app/03-api-reference/03-file-conventions/01-metadata/robots.mdxwith TS/JS examples and updatedRobotstype reference.Fixes #89521