Skip to main content
Version: 3.6.1

📦 create-docusaurus

一个脚手架实用程序,可帮助你立即设置功能性 Docusaurus 应用。

¥A scaffolding utility to help you instantly set up a functional Docusaurus app.

用法

¥Usage

npx create-docusaurus@latest [name] [template] [rootDir]

name 参数将用作站点的路径以及创建的应用的 package.json 中的 name 字段。可以是绝对路径,也可以是相对于 rootDir 的路径。

¥The name argument will be used as the site's path as well as the name field in the created app's package.json. It can be an absolute path, or a path relative to rootDir.

template 参数可以是以下之一:

¥The template argument can be one of the following:

  • classic:使用经典模板(推荐)

    ¥classic: Uses the classic template (recommended)

  • facebook:使用 Facebook/Meta 模板,其中包含一些特定于 Meta 的设置

    ¥facebook: Uses the Facebook/Meta template, which contains some Meta-specific setup

  • 一个 git repo URL(以 https://git@ 开头),可以克隆到目标

    ¥A git repo URL (beginning with https:// or git@), which can be cloned to the destination

  • 相对于 CWD 的本地文件路径,其中包含要复制到目标的文件

    ¥A local file path relative to CWD, which contains the files to be copied to destination

rootDir 将用于解析站点目录的绝对路径。默认为 CWD。

¥The rootDir will be used to resolve the absolute path to the site directory. The default is CWD.

警告

该命令最好在交互式 shell 中使用,以便所有功能都可用。

¥This command should be preferably used in an interactive shell so all features are available.

选项

¥Options

-t, --typescript

当模板参数是可识别的名称时使用。目前,只有 classic 提供了 TypeScript 变体。

¥Used when the template argument is a recognized name. Currently, only classic provides a TypeScript variant.

-g, --git-strategy

当模板参数是 git 存储库时使用。它必须是以下之一:

¥Used when the template argument is a git repo. It needs to be one of:

  • deep:保留完整的 git 历史记录

    ¥deep: preserves full git history

  • shallow:带有 --depth=1 的克隆

    ¥shallow: clones with --depth=1

  • copy:进行浅层克隆,但不创建 git 存储库

    ¥copy: does a shallow clone, but does not create a git repo

  • custom:输入你的自定义 git clone 命令。我们会提示你。你可以编写类似 git clone --depth 10 的内容,我们将附加存储库 URL 和目标目录。

    ¥custom: enter your custom git clone command. We will prompt you for it. You can write something like git clone --depth 10, and we will append the repository URL and destination directory.

-p, --package-manager

值应为 npmyarnpnpmbun 之一。如果未明确提供,Docusaurus 将根据以下条件推断:

¥Value should be one of npm, yarn, pnpm, or bun. If it's not explicitly provided, Docusaurus will infer one based on:

  • 锁定文件已存在于 CWD 中(例如,如果你在现有项目中设置网站)

    ¥The lockfile already present in the CWD (e.g. if you are setting up website in an existing project)

  • 用于调用 create-docusaurus 的命令(例如 npm initnpxyarn createbunx 等)

    ¥The command used to invoke create-docusaurus (e.g. npm init, npx, yarn create, bunx, etc.)

  • 交互式提示,以防所有启发式都不存在

    ¥Interactive prompting, in case all heuristics are not present

-s, --skip-install

如果提供,Docusaurus 在创建应用后不会自动安装依赖。--package-manager 选项仅在你实际安装依赖时才有用。

¥If provided, Docusaurus will not automatically install dependencies after creating the app. The --package-manager option is only useful when you are actually installing dependencies.