Rspress supports two formats of links: file path format and URL format. They render exactly the same results, differing only in code style.
Within the same Rspress project, it's recommended to use only one type of link format to maintain consistent code style.
The file path format uses absolute file paths or relative file paths to reference specific .md
or .mdx
files.
Here are examples from this website:
When using absolute paths, the root path is the docs
directory. If the project uses internationalization or multi-version, the markdown.link.autoPrefix
configuration will automatically add prefixes, so you can omit the language directory in links.
For example:
Absolute path - /guide/start/getting-started.mdx
Absolute path with language - /zh/guide/start/getting-started.mdx
Both will point to the same page.
We recommend using relative file paths as they have the following advantages:
You can directly navigate to the corresponding file in your IDE, and file links may be automatically updated when moving files.
They are supported by GitHub interface and other Markdown editors.
Compared to URL format, you don't need to consider the impact of the cleanUrls
configuration.
The URL format uses complete URL addresses to reference specific pages.
Here are examples from this website:
When using absolute paths, the root path is the docs
directory. If the project uses internationalization or multi-version, the markdown.link.autoPrefix
configuration will automatically add prefixes, so you can omit the language directory in links.
For example:
Absolute path - /guide/start/getting-started
Absolute path with language - /zh/guide/start/getting-started
Both will point to the same page.
The difference between URL format and file path format is that Rspress will automatically add the .html
suffix based on the cleanUrls
configuration, so you don't need to consider the .html
suffix in links - both with and without it will have consistent rendering results.
External links that are not in this docsite will automatically add target="_blank" rel="noreferrer"
:
Rspress also supports markdown's alternative definition
syntax for links, which can simplify link writing when there are many links.
Rspress supports adding anchor navigation in links, using the #
symbol to specify jumping to a specific position on the page.
During the maintenance of documentation sites, broken links often occur. Rspress provides a dead link checking feature to specifically address this troublesome maintenance issue.
Configure through markdown.link.checkDeadLinks to automatically check for invalid links.