自动迁移
迁移 CLI 工具会自动把你的 v1 站点迁移到 v2 版本。
信息
因为我们无法完全自动化迁移过程,所以你仍然需要在使用自动迁移工具之后,手动完成部分操作。
迁移 CLI 会迁移如下内容:
- 站点配置(
siteConfig.js
会被更新为docusaurus.config.js
) package.json
sidebars.json
/docs
/blog
/static
- 如果你的站点有多个版本,还会更新
versioned_sidebar.json
和/versioned_docs
迁移 CLI 的使用分为如下几步:
-
在使用迁移 CLI 之前,确保
/docs
、/blog
、/static
、sidebars.json
、siteConfig.js
、package.json
遵循预期的结构。 -
要开始迁移,请在正确的文件系统位置运行命令行工具:
# 迁移命令格式
npx @docusaurus/migrate migrate <v1 website directory> <desired v2 website directory>
# 示例
npx @docusaurus/migrate migrate ./v1-website ./v2-website
- 要在本地预览你的新网站,请前往 v2 站点目录并启动开发服务器。
- npm
- Yarn
- pnpm
cd ./v2-website
npm install
npm start
cd ./v2-website
yarn install
yarn start
cd ./v2-website
pnpm install
pnpm start
危险
迁移会 CLI 更新现有文件。 请务必先把它们提交到 git 上!