/sitecore-content-sdk-nextjs-pages-router:content-sdk-pages-router-sitemap-robotsfrom Sitecore Content SDK - Next.js Pages Router
Configures sitemap.xml, robots.txt, and llms.txt for Content SDK Pages Router apps via API routes and rewrites. Explains the trap where an empty RobotsContent field serves 'Disallow: /', blocking crawlers.
Ships in Sitecore Content SDK - Next.js Pages Router. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Sitemap, robots.txt and llms.txt are served via API routes and rewrites. Use the SDK middleware getHandler pattern and sites from .sitecore/sites.json.
src/pages/api/sitemap.ts with SitemapMiddleware(scClient, sites).getHandler(); robots: src/pages/api/robots.ts with RobotsMiddleware(scClient, sites).getHandler(). Use sites from .sitecore/sites.json. Add rewrites in next.config.js for /sitemap*.xml and /robots.txt to these API routes.The middleware serves nothing of its own — the body is CMS content. RobotsMiddleware resolves the site from the request host, then calls client.getRobots(siteName), which issues one Edge query:
query RobotsQuery($siteName: String!) {
site { siteInfo(site: $siteName) { robots } }
}
siteInfo.robots is the RobotsContent shared field on the site's Settings item — /sitecore/content/<Collection>/<Site>/Settings, field {64971FA7-F8AC-4C88-9BB2-2949F2A28670}, shown in Pages under Robots → Robots content. Changing robots.txt is a content edit, not a code change. This is identical in App Router; only the handler wrapper differs.
An empty RobotsContent field does NOT mean "no robots.txt" — it means Disallow: /. Sitecore composes the document server-side when the field is empty and returns a literal User-agent: *\nDisallow: /, which the middleware serves as a clean HTTP 200. Every crawler honours it, so a site with an untouched Settings item launches excluded from search while every other check is green. Verified against a live SitecoreAI CM 2026-08-12 across six sites: the five with an empty field all served the blocking document; the one with an authored value served it back verbatim.
Two consequences worth internalising:
The SDK's if (!robotsContent) branch is unreachable in practice. It exists to return a 404 when Edge yields nothing, but Edge never yields nothing — it always composes a document. The field is the only control surface, so "we didn't configure it" and "we blocked all crawlers" are the same state.
A publish is required. Preview and live return the same siteInfo.robots only while the field is empty, because both serve the same composed default; that equality says nothing about an authored value. Measured 2026-08-14 right after writing the field: preview returned Allow: / while live still returned Disallow: /. The write lands on master, preview Edge follows within seconds, and live Edge does not change until the Settings item is published. This field is subject to the usual preview/live divergence.
So verify against the live Edge context, never preview: a preview-side check passes while the public site stays blocked.
The default you almost always want:
User-Agent: *
Allow: /
Do not "fix" a blocking robots.txt with a static public/robots.txt. The rewrite would shadow the CMS-managed value and take robots.txt out of the author's reach permanently. Fix RobotsContent on the Settings item.
⚠️ Sitecore auto-appends a Sitemap: line to whatever the field contains, pointing at the CM host (https://xmc-….sitecorecloud.io/sitemap.xml) rather than the site's public domain — observed on every site measured, including correctly-configured ones. Verify it before treating the served robots.txt as production-correct.
src/pages/api/sitemap.ts — use new SitemapMiddleware(scClient, sites).getHandler(). Export the handler. Use sites from .sitecore/sites.json.src/pages/api/robots.ts — use new RobotsMiddleware(scClient, sites).getHandler(). Same pattern.src/pages/api/llms-txt.ts — use new LlmsTxtMiddleware(scClient, sites).getHandler() from @sitecore-content-sdk/nextjs/middleware, with a rewrite from /llms.txt. The content is managed in SitecoreAI; the SDK only serves it (no authoring UI, no generation).next.config.js, add rewrites for /robots.txt, /llms.txt and /sitemap*.xml to the corresponding API routes (e.g. /sitemap.xml → /api/sitemap).src/lib/sitecore-client.ts) as the rest of the app; do not create a dedicated client for sitemap/robots.public/robots.txt — it shadows the CMS-managed RobotsContent field and removes robots.txt from authoring control./robots.txt and read the body. Assert 200 and that it does not say Disallow: /. A 200 is not sufficient — the blocking default is served at 200.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub chris1415/sitecore-skills-pocs --plugin sitecore-content-sdk-nextjs-pages-router11 skills in this plugin
/content-sdk-pages-router-component-data-strategyComponent data in a Content SDK Pages Router app: getComponentData after getPage resolves component props for the layout. Use when wiring component data or BYOC in a Pages Router app. Not App Router./content-sdk-pages-router-component-registrationRegisters components in the generated .sitecore/component-map.ts of a Content SDK Pages Router app (regenerate, never hand-edit). Use when adding a component or layout or the editor cannot find one. Not App Router./content-sdk-pages-router-component-scaffoldCreates a new Sitecore component in a Content SDK Pages Router app: file layout, props interface, src/components/ placement, generated component map. Use when adding or scaffolding a component. Not App Router./content-sdk-pages-router-component-variantsImplements component variants: different renderings or data-driven variants of the same component type. Pages Router: register in .sitecore/component-map.ts; getComponentData resolves props. Use when one component has multiple presentations./content-sdk-pages-router-dictionary-and-i18nDictionary and i18n in a Content SDK Pages Router app: next.config i18n locales, context.locale, getDictionary after getPage. Use when adding translated content or changing locale behaviour. Not App Router./content-sdk-pages-router-editing-safe-renderingMakes Content SDK Pages Router components work in SitecoreAI editing and preview: context.preview, previewData, getPreview, design library data. Use when fixing editor or preview behaviour. Not App Router.Other plugins' skills for the same job