Basics
Project Structure
Section titled “Project Structure”Directorypublic/
- …
Directorysrc/
Directoryassets/
- …
Directorycontent/
Directorydocs/
- …
- content.config.ts
- astro.config.mjs
- package.json
- tsconfig.json
Common Commands
Section titled “Common Commands”| Command | Action |
|---|---|
npm install | Installs dependencies |
npm run dev | Starts local dev server at localhost:4321 |
npm run build | Build your production site to ./dist/ |
npm run preview | Preview your build locally, before deploying |
npm run astro ... | Run CLI commands like astro add, astro check |
npm run astro -- --help | Get help using the Astro CLI |
Adding Documents
Section titled “Adding Documents”-
Create a new
.mdxfile insrc/content/docs/. -
Add YAML front matter at the top of the file, otherwise it will not compile.
---title: title of the documentdescription: A description of the subject matter. It is displayed in the generated static page under the top title.---
Adding Custom CSS
Section titled “Adding Custom CSS”-
Create a CSS file, e.g.
src/styles/custom.css— the file name is not important. -
Update
astro.config.mjsto reference your CSS file.astro.config.mjs customCss: ['./src/styles/example1.css','./src/styles/example2.css',],
Sidebar Configuration
Section titled “Sidebar Configuration”Sidebar is configured by the astro.config.mjs file.
sidebar: [ { label: 'Intro', slug: 'guides/intro' }, // internal page { label: 'NASA', link: 'https://nasa.gov' }, // external link]Collapsible sections containing child pages.
{ label: 'Guides', items: [...], collapsed: false }Allows auto-generation of sidebar groups without editing astro.config.mjs.
_meta.yml files can be placed in a directory root to control behavior.
Plugin import:
import { autoSidebar } from '@astrojs/starlight/plugins';Example _meta.yml:
label: Astro Wiki # rename the directory group in the sidebarorder: 1 # sort this directory before othershidden: false # exclude from sidebarsort: reverse-slug # change sort order of contents to reverseExternal References
Section titled “External References” Starlight Docs Official Starlight documentation and component reference.
Astro Docs The official Astro framework documentation.