Skip to content

Quick Start

  • An existing Astro Starlight project
  • Node.js 18.0.0 or higher
  • Google Analytics 4 Measurement ID (optional but recommended)

No installation needed! Use npx to run directly:

Terminal window
npx astro-starlight-docs-template init

Or install globally:

Terminal window
npm install -g astro-starlight-docs-template
astro-starlight-docs-template init
Terminal window
cd my-astro-docs
Terminal window
npx astro-starlight-docs-template init

The CLI will ask you a series of questions:

🚀 Astro Starlight Docs Template v1.0.1
🔍 Checking if this is an Astro Starlight project...
✓ Astro project detected
? Google Analytics Measurement ID: G-XXXXXXXXXX
? Site URL: https://example.com
? Base path: /docs
? Author name: Your Name
? Twitter handle: yourhandle
? Add Cloudflare Web Analytics? No
? Create custom footer? Yes
? Add LLM optimization? Yes

The tool will create/modify:

  • public/cookie-consent.js - Cookie consent banner
  • astro.config.mjs - Analytics and consent mode setup
  • src/components/overrides/Footer.astro - Custom footer (if enabled)
  • public/llms.txt - LLM optimization (if enabled)
  • ASTRO_DOCS_OPTIMIZER.md - Documentation of changes
Terminal window
npm run build

Your documentation is now production-ready with:

  • ✅ Google Analytics with Consent Mode v2
  • ✅ GDPR-compliant cookie consent
  • ✅ SEO optimization
  • ✅ LLM support
  1. They see a cookie consent banner
  2. Analytics are denied by default
  3. Only after they click “Accept” will tracking begin
  4. They can change settings anytime via the footer link
  1. No banner shown (cleaner UX)
  2. Analytics granted by default
  3. Footer link available to opt-out if desired
  4. Better measurement quality
Terminal window
npm run dev

Visit http://localhost:4321 (or your configured port)

If you’re in a GDPR region (or using a VPN), you should see the cookie consent banner.

  • Go to your GA4 property
  • Navigate to Realtime reports
  • Browse your site
  • You should see the visit (if you accepted cookies)

Want to customize the setup? Check out:

  • Banner not showing? Check if you’re in a GDPR region or see Troubleshooting
  • Analytics not working? Verify your GA ID in astro.config.mjs
  • Footer not appearing? Make sure you selected “Yes” for custom footer

Now that your documentation is optimized, learn more about: