Skip to content

fix(rules): core/robots-meta reports X-Robots-Tag noindex and names the source #457 - #459

Merged
nc9 merged 1 commit into
mainfrom
fix/robots-meta-x-robots-tag-457
Oct 5, 2026
Merged

nc9 merged 1 commit into
mainfrom
fix/robots-meta-x-robots-tag-457

Conversation

@nc9

@nc9 nc9 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Part of #457 (the X-Robots-Tag half; skipping index rules on noindex pages is a separate PR because it changes scores).

What was wrong

core/robots-meta read only <meta name="robots">. A page kept out of the index by an X-Robots-Tag: noindex response header got no robots finding at all. crawl/indexability does 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-meta now reads ctx.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 tag
  • Page is set to noindex via X-Robots-Tag header
  • Page is set to noindex via X-Robots-Tag header for googlebot
  • Page is set to noindex via robots meta tag and X-Robots-Tag header
  • Page is set to noindex via X-Robots-Tag header for googlebot, nofollow via robots meta tag when 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: and unavailable_after: are directive values rather than crawler names, and a comma inside an unavailable_after date 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 reports X-Robots-Tag: <value>, and a page with both reports robots meta: <content>; X-Robots-Tag: <value>.

Visible change for existing users: the warning message for a meta-only noindex gains a via robots meta tag suffix.

The per-page rule-result cache already hashes securityHeaders (which carries xRobotsTag) into its key, and the rule stays verdictScope: "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/indexability related-rules list are updated.

Evidence

The issue's fixture served locally: /meta.html with <meta name="robots" content="noindex,nofollow">, /hdr.html with X-Robots-Tag: noindex, /bot.html with X-Robots-Tag: googlebot: noindex, and /a.html linking 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:

-score=31 summary={'passed': 356, 'warnings': 76, 'failed': 24}
+score=31 summary={'passed': 354, 'warnings': 78, 'failed': 24}
-core/robots-meta [warn] robots-meta: Page is set to noindex and nofollow pages=['meta.html'] value='noindex,nofollow'
+core/robots-meta [warn] robots-meta: Page is set to noindex and nofollow via robots meta tag pages=['meta.html'] value='noindex,nofollow'
+core/robots-meta [warn] robots-meta: Page is set to noindex via X-Robots-Tag header pages=['hdr.html'] value='X-Robots-Tag: noindex'
+core/robots-meta [warn] robots-meta: Page is set to noindex via X-Robots-Tag header for googlebot pages=['bot.html'] value='X-Robots-Tag: googlebot: noindex'

Nothing else in the report changed.

Tests

  • New packages/rules/tests/core-robots-meta.test.ts (21 tests): the parser (scoping, unscoped-before-scoped, value directives, ISO decimal-comma and RFC 850 unavailable_after dates, a digit-leading crawler such as 360Spider, 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 (parseXRobotsTag does not exist there).
  • rule-verdict-scope.test.ts passes (327).
  • tsgo --noEmit in packages/rules, oxlint and oxfmt on the changed files: clean. tangly check --strict in docs/: 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 (meaning noindex, nofollow) is not recognised, here or in isPageIndexable.
  • When a server sends X-Robots-Tag more 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.

@nc9
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
nc9 force-pushed the fix/robots-meta-x-robots-tag-457 branch from 5401f62 to 5306800 Compare October 5, 2026 07:46
@nc9
nc9 merged commit eea1bba into main Oct 5, 2026
14 checks passed
@nc9
nc9 deleted the fix/robots-meta-x-robots-tag-457 branch October 5, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant