docusaurus.config.js
Overview
docusaurus.config.js
contains configurations for your site and is placed in the root directory of your site.
它通常会导出一个站点配置对象:
module.exports = {
// site config...
};
Config files also support config creator functions and async code.
module.exports = function configCreator() {
return {
// site config...
};
};
module.exports = async function configCreatorAsync() {
return {
// site config...
};
};
module.exports = Promise.resolve({
// site config...
});
Required fields
title
- Type:
string
网站标题。 会用于页面元数据中,以及浏览器选项卡标题。
module.exports = {
title: 'Docusaurus',
};
url
- Type:
string
网站网址。 你可以把它看作是顶级主机名。 For example, http://facebook.github.io
is the URL of http://facebook.github.io/metro/, and http://docusaurus.io
is the URL for http://docusaurus.io. This field is related to the baseUrl
field.
module.exports = {
url: 'http://docusaurus.io',
};
baseUrl
- Type:
string
站点的 base URL。 可以被看作是主机名后的路径。 For example, /metro/
is the base URL of http://facebook.github.io/metro/. For URLs that have no path, the baseUrl should be set to /
. This field is related to the url
field. 开头和末尾始终要包含斜杠。
module.exports = {
baseUrl: '/',
};
Optional fields
favicon
- Type:
string | undefined
你的网站图标的路径;必须是可以用于链接 href 的 URL。 For example, if your favicon is in static/img/favicon.ico
:
module.exports = {
favicon: '/img/favicon.ico',
};
trailingSlash
- Type:
boolean | undefined
这个选项允许你自定义 URL/链接后是否添加末尾斜杠,以及静态 HTML 会如何被生成。
undefined
(default): keeps URLs untouched, and emit/docs/myDoc/index.html
for/docs/myDoc.md
true
: add trailing slashes to URLs/links, and emit/docs/myDoc/index.html
for/docs/myDoc.md
false
: remove trailing slashes from URLs/links, and emit/docs/myDoc.html
for/docs/myDoc.md
每个静态托管服务商在提供静态文件时的表现都有不同(甚至可能随着时间的推移而改变)。
Refer to the deployment guide and slorber/trailing-slash-guide to choose the appropriate setting.
i18n
- Type:
Object
The i18n configuration object to localize your site.
示例:
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'fa'],
path: 'i18n',
localeConfigs: {
en: {
label: 'English',
direction: 'ltr',
htmlLang: 'en-US',
calendar: 'gregory',
path: