Starlight is Astro’s documentation theme. It provides navigation, search (Pagefind), dark mode, i18n and accessible defaults. Use it for any docs or guide site.
- New project:
npm create astro@latest -- --template starlight. - Existing project with content: follow the manual setup in the Starlight docs.
- Update with
npx @astrojs/upgrade(updates Astro and official integrations together).
Content
Section titled “Content”- Pages live in
src/content/docs/; the file path is the URL. - Every page has
titleanddescription(the description is the meta description; keep it 120–160 characters). - Extend the schema rather than inventing ad-hoc fields:
docsSchema({ extend: z.object({ lastVerified: z.coerce.date().optional() }) }). Confirm the current API in the docs. - Use Starlight’s components (
Aside,Tabs,Steps,Card,LinkCard,Code) instead of custom HTML. - To show a file’s contents on a page, import it with
?rawand render with<Code>, so there is one source of truth.
Navigation
Section titled “Navigation”- Configure each sidebar group as
{ label: 'Group', items: [{ autogenerate: { directory: 'folder' } }] }and control order withsidebar.orderin frontmatter. (Puttinglabeldirectly on anautogenerateobject was removed in Starlight 0.39.) - Keep groups shallow (two levels).
Customising
Section titled “Customising”- Theme through CSS custom properties in a
customCssfile (accent and gray scales, fonts). - Change behaviour through component overrides in
components, importing and wrapping the default component rather than copying it. - Turn on
lastUpdated(needs full git history in CI) andeditLink.
Plugins (verify before adding)
Section titled “Plugins (verify before adding)”starlight-links-validator: fail the build on broken internal links.starlight-llms-txt: generatellms.txtfiles for language models.- Add any other plugin only with an ADR; community plugins vary in maintenance.
- Set
siteso canonicals and the sitemap are generated. - Add JSON-LD through a
Headoverride (see structured data). - Provide a default Open Graph image via
headconfig.
Checklist
Section titled “Checklist”- Every page has title + description
- Schema extended, not bypassed
- Sidebar autogenerated with orders
- Overrides wrap defaults
- Link validator in the build