部署
要为生产环境构建网站的静态文件,请运行:
- npm
- Yarn
- pnpm
npm run build
yarn build
pnpm run build
Once it finishes, the static files will be generated within the build
directory.
备注
The only responsibility of Docusaurus is to build your site and emit static files in build
.
现在,该由你来决定怎么托管这些静态文件了。
You can deploy your site to static site hosting services such as Vercel, GitHub Pages, Netlify, Render, and Surge.
Docusaurus 网站是静态渲染的,而且一般不需要 JavaScript 也能运行!
Configuration
The following parameters are required in docusaurus.config.js
to optimize routing and serve files from the correct location:
参数 | 描述 |
---|---|
url | 站点 URL。 For a site deployed at https://my-org.com/my-project/ , url is https://my-org.com/ . |
baseUrl | 站点的 base URL,带有末尾斜杠。 For a site deployed at https://my-org.com/my-project/ , baseUrl is /my-project/ . |
Testing your Build Locally
在部署到生产环境前,事先进行本地测试尤为重要。 Docusaurus provides a docusaurus serve
command for that:
- npm
- Yarn
- pnpm
npm run serve