Repository navigation
fix(rules): core/robots-meta reports X-Robots-Tag noindex and names the source #457 - #459
Merged
Merged
Conversation
nc9
marked this pull request as ready for review
October 5, 2026 07:46
…he source #457 core/robots-meta read only <meta name="robots">, so a page kept out of the index by an X-Robots-Tag header was reported nowhere (crawl/indexability reads the header but reports at info, which the report omits). The rule now reads the header too, parses crawler-scoped groups (X-Robots-Tag: googlebot: noindex), and says in its message whether the directive came from the meta tag, the header, or both, and for which crawler. Part of #457 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/robots-meta-x-robots-tag-457
branch
from
October 5, 2026 07:46
5401f62 to
5306800
Compare
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.
Part of #457 (the
X-Robots-Taghalf; skipping index rules on noindex pages is a separate PR because it changes scores).What was wrong
core/robots-metaread only<meta name="robots">. A page kept out of the index by anX-Robots-Tag: noindexresponse header got no robots finding at all.crawl/indexabilitydoes read the header, but it reports at info status and the report leaves info checks out, so the header was invisible. The bot-scoped form (X-Robots-Tag: googlebot: noindex) was invisible for the same reason.The fix
core/robots-metanow readsctx.page.headers["x-robots-tag"]next to the meta tag and names the source in its message:Page is set to noindex and nofollow via robots meta tagPage is set to noindex via X-Robots-Tag headerPage is set to noindex via X-Robots-Tag header for googlebotPage is set to noindex via robots meta tag and X-Robots-Tag headerPage is set to noindex via X-Robots-Tag header for googlebot, nofollow via robots meta tagwhen the two directives come from different places.The header parser (
parseXRobotsTag) follows Google's format: a crawler prefix scopes the directives after it until the next prefix (otherbot: noindex, nofollow),max-snippet:,max-image-preview:,max-video-preview:andunavailable_after:are directive values rather than crawler names, and a comma inside anunavailable_afterdate does not start a new crawler group. A crawler name must be a short product token containing a letter, so site-controlled header text cannot put arbitrary content into the message; up to five crawlers are named, with a count of the rest. An unscoped directive in the same header covers every crawler and folds the scoped ones away.Matching stays a lowercased substring test on the directives, as before, so statuses do not change: noindex warns, nofollow alone is info. The reported value is unchanged for meta-only pages (
noindex,nofollow); a header-only page reportsX-Robots-Tag: <value>, and a page with both reportsrobots meta: <content>; X-Robots-Tag: <value>.Visible change for existing users: the warning message for a meta-only noindex gains a
via robots meta tagsuffix.The per-page rule-result cache already hashes
securityHeaders(which carriesxRobotsTag) into its key, and the rule staysverdictScope: "page", so no cache or template fan-out change is needed.Docs: the rule page describes both sources, the scoped form, the message and value shapes, and the repeated-header limitation. The core index card and the
crawl/indexabilityrelated-rules list are updated.Evidence
The issue's fixture served locally:
/meta.htmlwith<meta name="robots" content="noindex,nofollow">,/hdr.htmlwithX-Robots-Tag: noindex,/bot.htmlwithX-Robots-Tag: googlebot: noindex, and/a.htmllinking to all three (no<h1>or meta description anywhere). Audited with the CLI from source,squirrel audit http://localhost:18457/ --http --offline --refresh -f json, before (origin/main 84b1fea) and after:Nothing else in the report changed.
Tests
packages/rules/tests/core-robots-meta.test.ts(21 tests): the parser (scoping, unscoped-before-scoped, value directives, ISO decimal-comma and RFC 850unavailable_afterdates, a digit-leading crawler such as360Spider, non-token prefixes) and the rule (no source, meta only with the raw value kept, header only, googlebot-scoped, several and more than five crawlers, unscoped folding, both sources, split clauses, header nofollow at info, crawler names not searched, case, pass wording, blank header). The file fails on main (parseXRobotsTagdoes not exist there).rule-verdict-scope.test.tspasses (327).tsgo --noEmitinpackages/rules, oxlint and oxfmt on the changed files: clean.tangly check --strictindocs/: all checks passed.Not covered
<meta name="googlebot">and other crawler-specific meta tags are still not read; the parser only extracts<meta name="robots">.none(meaningnoindex, nofollow) is not recognised, here or inisPageIndexable.X-Robots-Tagmore than once, the values reach rules comma-joined, so an unscoped header sent after a scoped one reads as part of the scoped group. Documented on the rule page.