Creating your site
Docusaurus 旨在让您的开源项目创建文档和网站变得更简单。
在 installation 和 preparation 之后,为您的文档创建基础站点的工作大部分已完成。
站点结构
您的网站结构如下所示:
root-directory
├── docs
└── website
├── blog
├── core
│ └── Footer.js
├── package.json
├── pages
├── sidebars.json
├── siteConfig.js
└── static
假设你删除了由 初始化 脚本所创建的示例
.md
文件。
您所有的文档文件都应该以 markdown .md
文件置于 docs
文件夹下。 任何博客文章都应在 blog
文件夹下。
博客的文章格式应统一为
YYYY-MM-DD-your-file-name.md
创建您的基础站点
创建一个功能齐备的网站,你只需要以下几步:
- 在
/docs
文件夹下添加您的.md
文档文件,确保每个文件中都包含 header 的头信息。 The simplest header would be the following, whereid
is the link name (e.g.,docs/intro.html
) and thetitle
is the webpage's title.
---
id: intro
title: Getting Started
---
My new content here..
```
1. Add zero or more docs to the [`sidebars.json`](/docs/zh-CN/navigation#adding-docs-to-a-sidebar) file so that your documentation is rendered in a sidebar, if you choose them to be.
> If you do not add your documentation to the `sidebars.json` file, the docs will be rendered, but they can only be linked to from other documentation and visited with the known URL.
3. Modify the `website/siteConfig.js` file to [configure your site](/docs/zh-CN/site-config), following the comments included in the [docs](/docs/zh-CN/site-config) and the `website/siteConfig.js` to guide you.
1. Create any [custom pages](/docs/zh-CN/custom-pages#customizing-your-site-footer) and/or [customize](/docs/zh-CN/custom-pages#customizing-your-site-footer) the `website/core/Footer.js` file that provides the footer for your site.
1. Place assets, such as images, in the `website/static/` directory.
1. Run the site to see the results of your changes.
```bash
cd website
yarn run start # or `npm run start`
# Navigate to http://localhost:3000
Special Customization
Docs Landing Page
If you prefer to have your landing page be straight to your documentation, you can do this through a redirect.
- Remove the
index.js
file from thewebsite/pages
directory, if it exists. - Add a custom static
index.html
page in thewebsite/static
directory with the following contents:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=docs/id-of-doc-to-land-on.html">
<script type="text/javascript">
window.location.href = 'docs/id-of-doc-to-land-on.html';
</script>
<title>Your Site Title Here</title>
</head>
<body>
If you are not redirected automatically, follow this <a href="docs/id-of-doc-to-land-on.html">link</a>.
</body>
</html>
You will get the
id
of the document to land on the.md
metadata of that doc page.
Blog Only
You can also use Docusaurus to host your blog only.