stringdocsSpecifies the document root directory. For example:
This config supports both relative and absolute paths, with relative paths being relative to the current working directory(cwd).
Of course, in addition to specifying the document root directory through the config file, you can also specify it through command line parameters, such as:
string/Deployment base path. For example, if you plan to deploy your site to https://foo.github.io/bar/, then you should set base to "/bar/":
string"Rspress"Site title. This parameter will be used as the title of the HTML page. For example:
string""Site description. This will be used as the description of the HTML page. For example:
string | URL""Site icon. This path will be used as the icon path for the HTML page. For example:
For normal path, Rspress will find your icon in the public directory, of course you can also set it to a CDN address, or use the file:// protocol or URL to use local absolute path.
string""Default language of the site. See Internationalization for more details.
string | { dark: string; light: string }""Site logo. This path will be used as the logo path in the upper left corner of the navbar. For example:
Rspress will find your icon in the public directory, you can also set it to a CDN address.
Of course you can set different logos for dark/light mode:
string""Site logo Text. This text will be used as the logo text in the upper left corner of the navbar. For example:
stringdoc_buildCustom output directory for built sites. for example:
Locale[]I18n config of the site. for example:
string | [string, Record<string, string>] | (route) => string | [string, Record<string, string>] | undefinedUsed to set additional elements rendered in the <head> tag of the page's HTML in production mode.
boolean | { selector?: string }trueWhether to enable the image zoom function. It is enabled by default, you can disable it by setting mediumZoom to false.
The bottom layer is implemented using the medium-zoom library.
Example usage:
stringundefinedYou can add search runtime hooks logic through the searchHooks parameter, for example:
For specific hook logic, you can read Customize Search Functions.
booleanfalseIf you are using multiVersion, the versioned parameter allows you to create a separate search index for each version of your documentation.
When enabled, the search will only query the index corresponding to the currently selected version.
booleantrueWhether to include code block content in the search index, which allows users to search code blocks.
(string | [string, object])[][]You can register global UI components through the globalUIComponents parameter, for example:
The item of globalUIComponents can be a string, which is the path of the component file, or an array, the first item is the path of the component file, and the second item is the component props, for example:
When you register global components, Rspress will automatically render these React components in the theme without manually importing and using them.
Through global components, you can complete many custom functions, such as:
In this way, the content of the component will be rendered in the theme page, such as adding BackToTop button.
In the meanwhile, you can also use the global component to register some side effects, such as:
This way, side effects of components are executed in the theme page. For example, some of the following scenarios require side effects:
{ default: string; versions: string[] }You can enable multi-version support through the multiVersion parameter, for example:
The default parameter is the default version, and the versions parameter is the version list.
ObjectCustom route config.
string[][]Add some extra files in the route. By default, only the files in the document root directory will be included in the route. If you want to add some extra files to the route, you can use this option. For example:
Note: The strings in the array support glob patterns, the glob expression should be based on the
rootdirectory of the document, with the corresponding extensions suffix.
We recommend using addPages hook in a custom Rspress plugin to add some additional files to the route, so that the page route and file path/content can be specified more flexibly and reasonably.
string[][]Exclude some files from the route. For example:
Note: The strings in the array support glob patterns, the glob expression should be based on the
rootdirectory of the document.
string[]['**/_[^_]*']A routing convention set for the convenience of users to use components in the docs directory, which excludes files starting with _ by default.
If you really need some routes starting with _, you can adjust this rule, for example, set it to exclude only files starting with _fragment-:
string[]['.js', '.jsx', '.ts', '.tsx', '.md', '.mdx']The extensions of the files that will be included in the route. By default, Rspress will include all 'js', 'jsx', 'ts', 'tsx', 'md', 'mdx' files in the route. If you want to customize the extensions, you can use this option. For example:
BooleanfalseGenerate url without suffix when cleanUrls is true for shorter url link.
boolean | { experimentalWorker?: boolean; experimentalLoose?: boolean; }trueWhether to enable static site generation. Rspress enable it by default to generate CSR outputs and SSG outputs.
If your document site is only required to be used in CSR scenarios, you can set ssg to false, and Rspress will only generate CSR outputs.
:::tips
SSG requires the source code to support SSR. If the code is not compatible to SSR, the build process will fail. You can try:
Fix code to make it SSR-compatible.
Set ssg: false, but the SSG feature will be lost.
:::
booleanfalseAfter enabled, you can use worker to accelerate the SSG process and reduce memory usage. It is suitable for large document sites and is based on tinypool.
(string | RegExp)[][]After enabled, some pages will not be rendered by SSG, and they will directly use html under CSR. This is suitable for SSG errors in large document sites bypassing a small number of pages. It is not recommended to enable this option actively.
{ search: string | RegExp; replace: string; }[][]You can set text replacement rules for the entire site through replaceRules. The rules will apply to everything including _meta.json files, frontmatter configurations, and document content and titles.
ObjectScans the md and mdx files in the document root directory to detect missing language versions, protect language parity.
booleanfalseWhether to enable language parity checks.
string[][]Specifies the folders to be checked, defaulting to all files in the document root directory. Paths should be relative to each language directory. For example:
string[][]Excludes certain folders and files from the checks.