🔥 All-Access Pass — $199 USD (Regular $499) · Unlock all 2,836 Astro themes ➔
komal.nakrani
Get All-Access Pass ($199)
ThemesCategoriesDocsBlogTips & TricksPricingGet All-Access Pass ($199)
Astro Fundamentals••By Komal Nakrani

Docusaurus to Starlight: A Step-by-Step Docs Migration

Migrate from Docusaurus to Starlight: move docs into a content collection, convert admonitions, frontmatter and sidebars, replace React components and keep URLs.

#Astro#Starlight#Docusaurus#Migration#Documentation

To migrate from Docusaurus to Starlight, create a Starlight project, copy your docs/ folder into src/content/docs/, convert Docusaurus frontmatter (sidebar_position, sidebar_label) to Starlight’s sidebar object, rebuild sidebars.js in the starlight() config, and swap @theme/* React components for Starlight’s built-in components. Admonitions mostly carry over, because both tools use the :::note directive syntax. The last step, and the one that protects your search traffic, is keeping every old URL working.

This guide walks a Docusaurus 3 site through that move to Starlight on Astro 7. If you’re still deciding, the Starlight vs Docusaurus comparison covers which tool fits which project.

Key Takeaways

  • Markdown and MDX content moves over with small edits; Docusaurus and Astro both use MDX 3.
  • Admonitions map directly except info (becomes note) and warning (becomes caution).
  • Docusaurus strips number prefixes from file names (01-intro.md becomes intro); Starlight doesn’t, so rename files or use redirects.
  • Docusaurus serves docs under /docs/ by default. Put files in src/content/docs/docs/ to keep that prefix.
  • Docs versioning and the built-in blog need community Starlight plugins or a separate Astro collection.

What maps to what

Docusaurus Starlight
docusaurus.config.js starlight() options in astro.config.mjs
docs/ src/content/docs/
sidebars.js sidebar option, with autogenerate for folders
_category_.json Sidebar group in config, or autogenerate plus page sidebar.order
sidebar_position: 2 sidebar: { order: 2 }
sidebar_label: Intro sidebar: { label: Intro }
slug: / id: frontmatter File path (or a redirect)
:::tip, :::note, :::danger Same syntax
:::info, :::warning :::note, :::caution
@theme/Tabs, @theme/TabItem Tabs, TabItem from @astrojs/starlight/components
static/ public/
src/pages/*.js (React pages) src/pages/*.astro or a splash page
Algolia DocSearch Pagefind search built in
swizzle Component overrides

Plain Markdown pages need almost no changes. The work is in the parts that are specific to Docusaurus: React components, custom sidebars and routing.

Step 1: Create the Starlight project

npm create astro@latest -- --template starlight my-docs
cd my-docs
npm run dev

The template registers the docs collection for you:

// src/content.config.ts
import { defineCollection } from 'astro:content';
import { docsLoader } from '@astrojs/starlight/loaders';
import { docsSchema } from '@astrojs/starlight/schema';

export const collections = {
  docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
};

Delete the example pages in src/content/docs/. The Astro project structure docs explain the remaining folders.

Step 2: Copy docs and decide on URLs

Before copying, decide where the pages should live, because that sets every URL:

  • Keep /docs/... URLs (Docusaurus default with routeBasePath: 'docs'): copy docs/ into src/content/docs/docs/.
  • Docs at the root (routeBasePath: '/'): copy the contents of docs/ straight into src/content/docs/.
# keep the /docs/ prefix
mkdir -p src/content/docs/docs
cp -R ../old-site/docs/* src/content/docs/docs/
cp -R ../old-site/static/* public/

Docusaurus drops numeric prefixes from IDs, so docs/01-getting-started/02-install.md is served at /docs/getting-started/install. Starlight uses the file path as is. Either rename files to drop the prefixes and control order with frontmatter, or keep the names and redirect. Renaming is cleaner:

# run from src/content/docs; strips "01-" style prefixes from files and folders
find . -depth -name '[0-9][0-9]-*' -execdir sh -c 'mv "$1" "${1#[0-9][0-9]-}"' _ {} \;

Also check for slug: in frontmatter. A page with slug: /quick-start lives at that URL in Docusaurus regardless of its file path. Move the file to match, or add a redirect in Step 6.

Step 3: Convert frontmatter and admonitions

Starlight requires title in frontmatter. Docusaurus can take the title from the first # Heading, so add title where it is missing and remove the duplicate H1. A Node script handles the sidebar fields and the two admonition types that differ:

// scripts/convert-docusaurus.mjs
import { readFileSync, writeFileSync, globSync } from 'node:fs';

for (const file of globSync('src/content/docs/**/*.{md,mdx}')) {
  let text = readFileSync(file, 'utf8');

  // sidebar_position / sidebar_label -> sidebar: { order, label }
  const order = text.match(/^sidebar_position:\s*(\d+)\s*$/m)?.[1];
  const label = text.match(/^sidebar_label:\s*(.+)$/m)?.[1];
  text = text.replace(/^sidebar_(position|label):.*\n/gm, '');
  if (order || label) {
    const lines = ['sidebar:'];
    if (order) lines.push(`  order: ${order}`);
    if (label) lines.push(`  label: ${label.trim()}`);
    text = text.replace(/^---\n/, `---\n${lines.join('\n')}\n`);
  }

  // admonitions that have different names
  text = text.replace(/^:::info/gm, ':::note').replace(/^:::warning/gm, ':::caution');

  writeFileSync(file, text);
}

Run it with node scripts/convert-docusaurus.mjs (fs.globSync needs Node.js 22, which Astro 7 requires anyway). Docusaurus 3 titled admonitions (:::tip[Title]) already match Starlight’s syntax. Review the diff, then run npm run build: schema errors name the file and field that need fixing.

Step 4: Rebuild the sidebar

Translate sidebars.js into the sidebar option. Explicit lists use page slugs; folders can be autogenerated and ordered by each page’s sidebar.order:

// astro.config.mjs
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

export default defineConfig({
  site: 'https://docs.example.com',
  integrations: [
    starlight({
      title: 'Example Docs',
      social: [{ icon: 'github', label: 'GitHub', href: 'https://github.com/example/project' }],
      editLink: { baseUrl: 'https://github.com/example/project/edit/main/' },
      sidebar: [
        { label: 'Start here', items: ['docs/intro', 'docs/install'] },
        { label: 'Guides', autogenerate: { directory: 'docs/guides' } },
        { label: 'API reference', autogenerate: { directory: 'docs/api' } },
      ],
    }),
  ],
});

_category_.json files become sidebar groups. Their label goes in the config and their position decides the group order in the array. Docusaurus navbar items have no direct equivalent: top-level sections usually become sidebar groups, and external links can be sidebar entries with a link.

Step 5: Replace React components

Docusaurus MDX pages often import theme components. Starlight’s built-ins cover the common ones:

---
title: Install
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs syncKey="pkg">
  <TabItem label="npm">
    ```bash
    npm install example
    ```
  </TabItem>
  <TabItem label="pnpm">
    ```bash
    pnpm add example
    ```
  </TabItem>
</Tabs>

Docusaurus TabItem uses value and label; Starlight only needs label, and syncKey replaces groupId. Other swaps:

  • @theme/CodeBlock becomes a fenced code block, or Starlight’s Code component for dynamic code. Code titles use title="file.js" in the fence meta.
  • @site/src/components/* React components can stay React: run npx astro add react and use them in .mdx with a client:* directive if they’re interactive. Static ones are usually quicker to rewrite as Astro components.
  • useDocusaurusContext() and other Docusaurus hooks have no equivalent. Replace them with imports from your config or plain props.
  • <details> works unchanged.

The MDX guide covers imports and props in .mdx files, and the React components in Astro guide covers hydration.

Step 6: Keep old URLs working

Docusaurus doesn’t add .html by default, so if your URLs and folder layout match, most pages keep the same path. The differences come from removed number prefixes, slug: overrides, versioned docs and blog posts. Add a redirect for each:

// astro.config.mjs (add to defineConfig)
redirects: {
  '/docs/getting-started/install': '/docs/install/',
  '/quick-start': '/docs/quick-start/',
},

Static builds write a small HTML redirect page for each entry. A host-level 301 is better for search engines; the redirects tip shows both, and the site migration SEO checklist covers crawling the old sitemap to make sure nothing is missed.

Three Docusaurus features need a decision:

  • Versioned docs. Starlight has no built-in versioning. The community starlight-versions plugin adds it, or you can deploy each major version to its own subdomain.
  • Blog. Use the community starlight-blog plugin, or a regular Astro content collection with its own pages. The Astro blog guide covers the second option.
  • Search. Pagefind runs at build time and needs no setup. Remove the Algolia config; if you want to keep DocSearch, Starlight has an official DocSearch plugin.

Deploy and verify

Starlight builds to dist/ instead of build/. Update the output directory on your host, then run npm run build && npm run preview and click through the sidebar. Check that search returns results, edit links point at the right files, and old URLs redirect. The static deploy docs cover the host settings.

If the docs sit next to a product site, the Documentation Astro themes show designed docs layouts, and Starlight can share header and footer components with them through overrides. Starlight’s own migration and configuration docs list every option used above.

FAQ

How long does it take to migrate from Docusaurus to Starlight?

A site that is mostly Markdown with a few admonitions and tabs can move in a day. Heavily customized sites with swizzled components, custom plugins or versioned docs take longer, because each of those needs a Starlight equivalent or a rewrite.

Do Docusaurus admonitions work in Starlight?

Mostly. Both use the :::type directive syntax with ::: to close. note, tip and danger work as is; rename info to note and warning to caution. Titled admonitions written as :::tip[Title] carry over unchanged.

Can I keep my React components when moving to Starlight?

Yes. Add the React integration with npx astro add react and import the components in .mdx pages. Add a client:* directive only to components that need interactivity in the browser; static ones render to plain HTML.

Does Starlight support versioned docs like Docusaurus?

Not built in. The community starlight-versions plugin adds versioned docs and a version picker. Some teams publish each major version as a separate deployment instead.

Will my URLs change when I migrate from Docusaurus to Starlight?

They can. Pages with numeric file prefixes, slug: overrides or a different base path end up at new URLs unless you rename files or add redirects. Map every old URL before launch and add 301 redirects for anything that moved.