> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/getting-started/import.md).

# 迁移到 GitBook

了解如何将现有内容从 Confluence、Notion、Git 等导入到 GitBook

您可以使用导入工具在 GitBook 中迁移并整合现有文档。

您可以使用我们内置的导入工具导入单个或多个页面，也可以 [使用 Git Sync 导入整个 Git 仓库](#import-using-git-sync).

## 使用导入面板

导入面板可让您轻松将内容从其他文档网站或现有文件迁移到您的 GitBook 组织中。

当您选择从其他在线文档站点导入时，只需添加该站点的 URL，GitBook 就会处理其余部分。

默认情况下，GitBook 会使用 AI 来简化导入流程。它会智能地优化并清理与 GitBook 格式不完全匹配的导入内容——这意味着输出结果会更精致，并更有效地使用 GitBook 的区块。您可以在菜单中将其禁用。

### 支持的导入格式

GitBook 支持从文档网站或以下格式的文件导入：

* Markdown（`.md` 或 `.markdown`)
* HTML（`.html`)
* Microsoft Word（`.docx`)

GitBook 也支持从以下来源导入：

* Confluence
* Notion
* GitHub Wiki
* Quip
* Dropbox Paper
* Google 文档

如果您想 **导入多个页面**，可以上传包含 HTML 或 Markdown 文件的 ZIP 文件，或使用 **在线文档** 导入选项。

{% hint style="info" %}
GitBook 基于 Markdown，因此以 Markdown 格式导入内容将获得最佳效果。如果您当前的工具支持导出为 Markdown，我们建议使用该格式，以获得更顺畅的导入过程。
{% endhint %}

### 导入面板

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-fee6329e5d4ed9522490f472129a8a1a1efceea1%2F25_12_10_import%402x.png?alt=media" alt="A GitBook screenshot showing the import panel"><figcaption><p>GitBook 中的导入面板。</p></figcaption></figure>

创建新分区时，您可以在弹出的对话框中选择导入内容。如果创建的是空分区，也可以在点击 **编辑** 后，通过新建空白页面底部的 **编辑**.

快速入门 **部分导入。您也可以随时通过选择** > **添加新内容** 页面底部的 [目录](https://gitbook.com/docs/documentation/zh/can-kao/gitbook-ui.md#table-of-contents)中的 **操作菜单** <picture><source srcset="broken://files/YjlF3Z9KMYv9aQiFzZKD" media="(prefers-color-scheme: dark)"><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-aabbca522107ef561981bdfe5af94605b31e0920%2F25_01_10_actions_icon_light.svg?alt=media" alt="The Actions menu icon in GitBook"></picture> ，然后选择 **导入子页面**.

选择输入源后，您可以选择要导入的文件。

{% hint style="warning" %}
GitBook 可从多种来源导入内容，但由于产品功能和文档格式的差异，导入内容可能与原始来源有所不同。
{% endhint %}

### 限制

GitBook 目前对导入内容有以下限制：

* 单次导入最多可上传的页面数为 **20**.
* 单次导入最多可上传的文件（图片等）数量为 **20**.

GitBook 无法提高这些导入限制。若要一次导入更多内容，请使用 [Git Sync](https://gitbook.com/docs/documentation/zh/docs-as-code/git-sync.md)，最多支持 5,000 个 Markdown 页面。

***

## 使用 Git Sync 从 GitHub 或 GitLab 仓库导入 <a href="#import-using-git-sync" id="import-using-git-sync"></a>

向 GitBook 导入大量内容时，我们建议使用 [Git Sync](https://gitbook.com/docs/documentation/zh/docs-as-code/git-sync.md)。虽然我们的内置迁移工具可以处理大多数导入任务，但 Git Sync 更适合高效处理大规模迁移。

{% hint style="info" %}
以下是导入内容的基本步骤。如需查看更详细的步骤和视频演示，请参阅专门介绍 [如何使用 Git Sync 将内容导入 GitBook](https://gitbook.com/docs/guides/editing-and-publishing-documentation/import-or-migrate-your-content-to-gitbook-with-git-sync.md).
{% endhint %}

{% stepper %}
{% step %}
**将您的内容转换为 Markdown**

GitBook 基于 Markdown，因此以 Markdown 格式导入内容将获得最佳效果。如果您当前的工具支持导出为 Markdown，我们建议使用该格式，以获得更顺畅的导入过程。

如果您的内容还不是 Markdown 文件，我们建议使用脚本（例如 [Markitdown](https://github.com/microsoft/markitdown)）或在线工具进行转换。
{% endstep %}

{% step %}
**在 GitHub 或 GitLab 中整理您的内容**

在设置您的 GitBook 站点时，高效地整理 GitHub 或 GitLab 仓库中的内容至关重要。由于 Git Sync 是在分区级别进行的，请仔细规划如何对内容进行分组。创建多个仓库或文件夹，并确保所需的 Markdown 文件位于正确的位置。
{% endstep %}

{% step %}
**设置分区并配置 Git Sync**

为了整理内容，请根据需要在 GitBook 中创建一个或多个分区。安装 [GitHub 同步](https://www.gitbook.com/integrations/github-sync) 或 [GitLab 同步](https://www.gitbook.com/integrations/gitlab-sync) 集成，并为这些分区进行配置。你需要将分区与上一步设置的文件夹或仓库同步。
{% endstep %}

{% step %}
**按 GitHub → GitBook 方向运行 Git Sync**

在进行配置时，请确保选择 GitHub → GitBook 方向。这样，您文件夹或仓库中的内容就会从 GitHub 或 GitLab 拉取到 GitBook 中。
{% endstep %}
{% endstepper %}

## 导出您的内容

您可以通过两种方式导出 GitBook 内容：

* **以 Markdown 格式**通过与 Git 仓库同步。目前应用中不支持直接导出 Markdown；请使用 [Git Sync](https://gitbook.com/docs/documentation/zh/docs-as-code/git-sync.md)，而仓库会成为你的 Markdown 导出内容。某些块没有对应的 Markdown 表示形式，因此会以 HTML 的形式出现在导出内容中。
* **导出为 PDF**，可在页面或章节的“操作”菜单中选择。请参阅 [PDF 导出](https://gitbook.com/docs/documentation/zh/publish/pdf-export.md)。导出特别大的章节时可能会遇到限制。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/getting-started/import.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
