SEO/GEO/GSC: sitemap index + caching, Search & AI settings, getRobots
- Sitemap: batched reads (500), published-only where, field select; sitemap index over maxUrls (default 10k) with ?part=N; Cache-Control; in-process memo; runtime errors → 503 Retry-After (empty urlset only during next build) - Site Settings → Search & AI tab (seo.searchSettings: false removes it): Google/Bing/Yandex verification (paste code or whole meta tag) added to page metadata; AI crawler policy + per-bot exceptions; llms.txt note - buildRobots aiBotRules; getRobots helper reads the panel; more AI agents - Under construction: sitemap and llms.txt list only open pages - collectSiteIndex: no silent 1000 cap; llms routes send Cache-Control - IndexNow: nothing sent with IPAL_NOINDEX - Unknown route metadata is noindex - Tests (unit + SQLite integration) and docs/seo.md Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
12fbd424a5
commit
94e563055f
@@ -12,12 +12,15 @@ type RobotRule = { allow?: string; disallow?: string[]; userAgent: string | stri
|
||||
*/
|
||||
export const AI_ASSISTANT_BOTS = [
|
||||
'ClaudeBot',
|
||||
'Claude-User',
|
||||
'Claude-Web',
|
||||
'Claude-SearchBot',
|
||||
'ChatGPT-User',
|
||||
'OAI-SearchBot',
|
||||
'PerplexityBot',
|
||||
'Perplexity-User',
|
||||
'MistralAI-User',
|
||||
'DuckAssistBot',
|
||||
] as const
|
||||
|
||||
export const AI_TRAINING_BOTS = [
|
||||
@@ -30,7 +33,10 @@ export const AI_TRAINING_BOTS = [
|
||||
'Meta-ExternalAgent',
|
||||
] as const
|
||||
|
||||
type AiBotsPolicy = 'allow' | 'block-training' | 'disallow' | false
|
||||
export type AiBotsPolicy = 'allow' | 'block-training' | 'disallow' | false
|
||||
|
||||
/** One bot treated differently from the policy, e.g. { userAgent: 'Bytespider', access: 'disallow' }. */
|
||||
export type AiBotRule = { access: 'allow' | 'disallow'; userAgent: string }
|
||||
|
||||
export type RobotsOptions = {
|
||||
/**
|
||||
@@ -41,6 +47,12 @@ export type RobotsOptions = {
|
||||
adminRoute?: false | string
|
||||
/** Override the assistant/search bot list. */
|
||||
aiAssistantAgents?: readonly string[]
|
||||
/**
|
||||
* Per-bot exceptions that win over `aiBots` — a listed bot leaves its policy
|
||||
* group and gets its own allow or block. Unknown bots can be added this way.
|
||||
* Site Settings → Search & AI fills it when you use `getRobots`.
|
||||
*/
|
||||
aiBotRules?: readonly AiBotRule[]
|
||||
/**
|
||||
* How to treat AI crawlers (assistant/search + training). Default 'allow' —
|
||||
* explicitly welcome them so the site stays visible to Claude, ChatGPT,
|
||||
@@ -118,6 +130,7 @@ export type RobotsRules = {
|
||||
export function buildRobots({
|
||||
adminRoute = '/admin',
|
||||
aiAssistantAgents = AI_ASSISTANT_BOTS,
|
||||
aiBotRules = [],
|
||||
aiBots = 'allow',
|
||||
aiTrainingAgents = AI_TRAINING_BOTS,
|
||||
baseUrl,
|
||||
@@ -139,15 +152,32 @@ export function buildRobots({
|
||||
|
||||
const baseRule: RobotRule = { allow: '/', disallow, userAgent: '*' }
|
||||
|
||||
const aiRules: RobotRule[] = []
|
||||
if (aiBots === 'allow') {
|
||||
aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })
|
||||
} else if (aiBots === 'block-training') {
|
||||
aiRules.push({ allow: '/', disallow, userAgent: [...aiAssistantAgents] })
|
||||
aiRules.push({ disallow: ['/'], userAgent: [...aiTrainingAgents] })
|
||||
} else if (aiBots === 'disallow') {
|
||||
aiRules.push({ disallow: ['/'], userAgent: [...aiAssistantAgents, ...aiTrainingAgents] })
|
||||
// Exceptions: last rule per bot wins; those bots leave the policy groups.
|
||||
const exceptions = new Map<string, AiBotRule>()
|
||||
for (const r of aiBotRules) {
|
||||
const ua = r.userAgent.trim()
|
||||
if (ua) {exceptions.set(ua.toLowerCase(), { access: r.access, userAgent: ua })}
|
||||
}
|
||||
const notExcepted = (list: readonly string[]) => list.filter((ua) => !exceptions.has(ua.toLowerCase()))
|
||||
const assistants = notExcepted(aiAssistantAgents)
|
||||
const training = notExcepted(aiTrainingAgents)
|
||||
|
||||
const aiRules: RobotRule[] = []
|
||||
const push = (rule: RobotRule) => {
|
||||
if (rule.userAgent.length) {aiRules.push(rule)}
|
||||
}
|
||||
if (aiBots === 'allow') {
|
||||
push({ allow: '/', disallow, userAgent: [...assistants, ...training] })
|
||||
} else if (aiBots === 'block-training') {
|
||||
push({ allow: '/', disallow, userAgent: assistants })
|
||||
push({ disallow: ['/'], userAgent: training })
|
||||
} else if (aiBots === 'disallow') {
|
||||
push({ disallow: ['/'], userAgent: [...assistants, ...training] })
|
||||
}
|
||||
const allowed = [...exceptions.values()].filter((r) => r.access === 'allow').map((r) => r.userAgent)
|
||||
const blocked = [...exceptions.values()].filter((r) => r.access === 'disallow').map((r) => r.userAgent)
|
||||
push({ allow: '/', disallow, userAgent: allowed })
|
||||
push({ disallow: ['/'], userAgent: blocked })
|
||||
|
||||
return {
|
||||
rules: aiRules.length > 0 ? [baseRule, ...aiRules] : baseRule,
|
||||
|
||||
Reference in New Issue
Block a user