Skip to main content
Version: Canary 🚧

自动化迁移

迁移CLI自动将您的v1网站迁移到v2网站。

info

使用迁移CLI后仍需要手动工作,因为我们无法自动化完整的迁移

迁移CLI迁移:

  • 站点配置(从 siteConfig.jsdocusaurus.config.js
  • package.json
  • sidebars.json
  • /docs
  • /blog
  • /static
  • versioned_sidebar.json/versioned_docs 如果你的网站使用了版本控制

要使用迁移CLI,请按照以下步骤操作:

  1. 在使用迁移CLI之前,请确保/docs/blog/staticsidebars.jsonsiteConfig.jspackage.json遵循预期的结构。

  2. 要迁移您的v1网站,请使用适当的文件系统路径运行迁移CLI:

# migration command format
npx @docusaurus/migrate migrate <v1 website directory> <desired v2 website directory>

# example
npx @docusaurus/migrate migrate ./v1-website ./v2-website
  1. 要在本地查看您的新网站,请进入您的v2网站目录并启动您的开发服务器。
cd ./v2-website
npm install
npm start
danger

迁移CLI会更新现有文件。请确保首先提交它们!

选项

你可以向迁移CLI添加选项标志,以自动将Markdown内容和页面迁移到v2。你可能仍然需要进行一些手动更改以达到你想要的结果。

NameDescription
--mdxAdd this flag to convert Markdown to MDX automatically
--pageAdd this flag to migrate pages automatically
# example using options
npx @docusaurus/migrate migrate --mdx --page ./v1-website ./v2-website
danger

页面和MDX的迁移仍在进行中。

我们建议您尝试在没有这些选项的情况下运行页面,提交,然后尝试使用--page--mdx选项再次运行迁移。

这样,您将能够轻松检查和修复差异。