跳转至主内容
Version: 2.0.0-beta.0

迁移概览

此文档将教授您如何将现有的 Docusaurus 1 网站更新至 Docusaurus 2。

我们尽力精简这一流程,且提供了迁移 CLI 工具。

主要差异#

Docusaurus 1 是一款纯静态站点生成器,服务端使用 React 作为模板引擎,但浏览器端不加载 React。

Docusaurus 2 is rebuilt it from the ground up, generates a single-page-application, using the full power of React in the browser. 新版本可以让您深度定制,同时保留了 Docusaurus 1 的优点――易于上手、分版文档和 i18n。

除此之外,Docusaurus 2 还是一款性能卓越的静态网站生成器,您还可用它来快速创建常见的内容驱动站点。(如开发文档、博客、产品着陆及营销页面)

虽然我们的重心仍是为您又快又好地呈现开发文档,但您也可以让 Docusaurus 2 如其他的 React 应用一般构建出任意类型的网站。 Docusaurus 现已可以构建任意类型的站点,不单单局限于开发文档网站。

Docusaurus 1 架构#

Your Docusaurus 1 site should have the following structure:

├── docs└── website    ├── blog    ├── core    │   └── Footer.js    ├── package.json    ├── pages    ├── sidebars.json    ├── siteConfig.js    └── static

Docusaurus 2 架构#

After the migration, your Docusaurus 2 site could look like:

├── docs└── website    ├── blog    ├── src    │   ├── components    │   ├── css    │   └── pages    ├── static    ├── package.json    ├── sidebars.json    ├── docusaurus.config.js
信息

This migration does not change the /docs folder location, but Docusaurus v2 sites generally have the /docs folder inside /website

You are free to put the /docs folder anywhere you want after having migrated to v2.

迁移流程#

There are multiple things to migrate to obtain a fully functional Docusaurus 2 website:

  • 软件包
  • CLI 命令
  • 站点配置
  • Markdown 文件
  • 侧边栏文件
  • 页面、 组件和 CSS
  • 分版文档
  • i18n 支持🚧

自动迁移流程#

The migration cli will handle many things of the migration for you.

However, some parts can't easily be automated, and you will have to fallback to the manual process.

note

We recommend running the migration cli, and complete the missing parts thanks to the manual migration process.

手动迁移流程#

Some parts of the migration can't be automated (particularly the pages), and you will have to migrate them manually.

The manual migration guide will give you all the manual steps.

支持#

For any questions, you can ask in the #docusaurus-1-to-2-migration Discord channel.

Feel free to tag @slorber in any migration PRs if you would like us to have a look.

We also have volunteers willing to help you migrate your v1 site.

迁移合并请求示例#

您可以参考我们为 Create React AppFlux 提交的迁移合并请求来了解如何迁移简单的 Docusaurus v1 网站。