Setting Up
本教程是针对首次使用者的,详细地说明如何从零开始完成一个的Docusaurus网站。 让我们开始吧!
{.docImage}
安装 Git
Git 是一个版本控制系统,用于在软件开发过程中跟踪源代码的更改,它可以帮助您在本地系统和您的在线存储库之间同步和版本文件。 Windows 的Git包括 Git Bash(终端应用程序)。 如果尚未安装,请参阅安装 Git。
Install Node.js
Node.js is an environment that can run JavaScript code outside of a web browser and is used to write and run server-side JavaScript apps. Node.js安装包含 npm
(软件包管理器允许您从终端安装NPM 模块)。
- 在 Mac、Linux 或 Unix 系统上打开终端。 在 Windows 系统上打开 Git Bash
- 如果您在 系统 上有
brew
,请运行以下命令来安装节点。
brew install node
Alternatively, you can download an installer from the Node.js homepage.
Check your Node.js installation
Check that you have the minimum required version installed by running the following command:
node -v
You should see a version larger than Node 8.
node -v
v8.15.1
Docusaurus' minimum supported Node.js version is Node 8, but more recent versions will work as well.
Install Yarn (Optional)
We highly recommend that you install Yarn, an alternative package manager that has superb performance for managing your NPM dependencies. Check it out here.
You can still proceed with the tutorial without Yarn.
Create a GitHub repository and local clone
- Go to https://github.com/ and sign up for an account if you don't already have one.
- Click on the green New button or go to https://github.com/new.
- Type a repository name without spaces. For example,
docusaurus-tutorial
. - Click Create repository (without
.gitignore
and without a license).
{.docImage}
- 在 Terminal 或 Git Bash,
cd
到一个目录, 代码将会克隆到该目录的子目录。
cd /Users/NAME/doc_projects # macOS example
# or
cd /c/NAME/doc_projects # Windows example
- Clone your repository to your local machine:
git clone git@github.com:USERNAME/docusaurus-tutorial.git # SSH
# or
git clone https://github.com/USERNAME/docusaurus-tutorial.git # HTTPS
Install the Docusaurus init command
Docusaurus comes with a command line tool to help you scaffold a Docusaurus site with some example templates. Let's install the installer!
Run the following command:
npm install --global docusaurus-init
or if you have Yarn:
yarn global add docusaurus-init