Build production-grade documentation sites with Astro Starlight. This skill covers everything from initial scaffolding to advanced customization and deployment.
/docs/), Vercel, Netlify, Cloudflare PagesBefore writing any code, read the relevant reference file(s) from references/:
TaskRead firstNew project or project structurereferences/project-setup.mdSidebar, navigation, frontmatterreferences/sidebar-and-content.mdStyling, theming, Tailwindreferences/styling-and-theming.mdMDX components, custom componentsreferences/components.mdDeployment, subpaths, search, i18nreferences/deployment-and-advanced.mdSomething broken?references/troubleshooting.md
For most tasks, read project-setup.md first, then the topic-specific file.
bash
npm create astro@latest -- --template starlight
This gives you a working project with:
text
my-docs/
├── astro.config.mjs # Starlight integration config
├── src/
│ ├── content/
│ │ └── docs/ # All doc pages live here
│ │ └── index.mdx
│ └── content.config.ts # Content collection schema
├── public/ # Static assets (favicon, images)
└── package.json
This is the most important step. Your folder structure = your URL structure = your sidebar structure. Plan it before writing content. See references/sidebar-and-content.md for patterns.
astro.config.mjs#The Starlight integration is configured here. Minimum viable config:
js
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';
export default defineConfig({
integrations: [
starlight({
title: 'My Docs',
sidebar: [
{
label: 'Guides',
autogenerate: { directory: 'guides' },
},
],
}),
],
});
src/content/docs/#Every .md or .mdx file needs frontmatter with at least title:
yaml
---
title: Getting Started
description: How to get started with our product.
sidebar:
order: 1
---
bash
npm run build # Outputs to dist/
npm run preview # Preview the build locally
.mdx only when you need component imports. Plain .md is simpler and avoids hydration issues.sidebar.order to control page ordering within autogenerated groups./docs/, you must set both site and base in astro.config.mjs. See references/deployment-and-advanced.md..mdx files, not .md. If you get import errors, check your file extension.@astrojs/starlight-tailwind compatibility package. Without it, styles will fight each other.base isn't configured correctly.client:load (or another client directive) if they use JavaScript/interactivity. Without it, they render as static HTML only.Read these for detailed guidance. Each is self-contained and covers one topic area thoroughly:
references/project-setup.md — Scaffolding, project structure, astro.config.mjs anatomy, content collectionsreferences/sidebar-and-content.md — Sidebar config patterns, frontmatter reference, content authoring, orderingreferences/styling-and-theming.md — Custom CSS, Tailwind integration, theming, dark mode, Expressive Codereferences/components.md — Built-in components (Tabs, Cards, Asides, etc.), custom components in MDX, hydrationreferences/deployment-and-advanced.md — Deployment targets, subpath hosting, search, i18n, versioning, auth, SSRreferences/troubleshooting.md — Diagnosis and fixes for the most common Starlight issues