Starlight Notes
Installing Starlight
Section titled “Installing Starlight”-
Install Node.js to get
npmnode -v -
Update
npmto the latest versionnpm -vnpm install -g npm@latest -
Create a new Astro + Starlight project
npm create astro@latest -- --template starlightnpm warn "starlight" is being parsed as a normal command line argument.npm warn Unknown cli config "--template". This will stop working in the next major version of npm.Need to install the following packages:create-astro@5.0.5Ok to proceed? (y)> npx> create-astro starlightdir Using starlight as project directoryHow would you like to start your new project?- A basic, helpful starter project (recommended)- Use blog template- Use docs (Starlight) template- Use minimal (empty) template Unable to fetch latest astro version from the npm registry. Using 6.1.2 instead.Install dependencies? (recommended)Initialize a new git repository? (optional)cd starlightnpm run dev (q + Enter to stop)Use astro add to add frameworks like react or tailwind
Updating Starlight
Section titled “Updating Starlight”-
Update Starlight to the latest version
npx @astrojs/upgrade
Deploy to GitHub Pages (gh-pages branch)
Section titled “Deploy to GitHub Pages (gh-pages branch)”-
Configure Starlight for GitHub Pages by adding
siteandbasetoastro.config.mjs:// @ts-checkimport { defineConfig } from 'astro/config';import starlight from '@astrojs/starlight';// https://astro.build/configexport default defineConfig({site: 'https://username.github.io',base: '/my-repo',integrations: [starlight({title: 'My Docs',social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/withastro/starlight' }],sidebar: [{label: 'Guides',items: [// Each item here is one entry in the navigation menu.{ label: 'Example Guide', slug: 'guides/example' },],},{label: 'Reference',autogenerate: { directory: 'reference' },},],}),],}); -
Run
npm run buildto generate thedist/folder -
Create an empty file named
dist/.nojekyll
(this tells GitHub Pages not to use Jekyll, which can break Astro/Starlight’s asset paths) -
Deploy the contents of the
dist/folder to thegh-pagesbranch- Remove
dist/from.gitignore git add dist && git commit -m "Update dist for deployment" && git pushgit subtree push --prefix dist origin gh-pages
- Remove
-
Configure the GitHub Repository to deploy GitHub Pages from the
gh-pagesbranch- Go to GitHub > repository > Settings > Pages
- Under Build and deployment, select Deploy from a branch for Source
- Set the Branch to
gh-pagesand the folder to/(root)