docs(v2): GH pages: recommend using trailingSlash (#5033)

This commit is contained in:
Sébastien Lorber 2021-06-22 11:25:34 +02:00 committed by GitHub
parent f20599bb54
commit 41eaa690ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -47,6 +47,17 @@ export default async function deploy(
customOutDir: cliOptions.outDir,
});
if (typeof siteConfig.trailingSlash === 'undefined') {
console.warn(
chalk.yellow(`
Docusaurus recommendation:
When deploying to GitHub Pages, it is better to use an explicit "trailingSlash" site config.
Otherwise, GitHub Pages will add an extra trailing slash to your site urls only on direct-access (not when navigation) with a server redirect.
This behavior can have SEO impacts and create relative link issues.
`),
);
}
console.log('Deploy command invoked...');
if (!shell.which('git')) {
throw new Error('Git not installed or on the PATH!');

View file

@ -90,7 +90,7 @@ You may refer to GitHub Pages' documentation [User, Organization, and Project Pa
:::caution
GitHub Pages adds a trailing slash to Docusaurus URLs by default. Adjusting the `trailingSlash` setting can be useful.
GitHub Pages adds a trailing slash to Docusaurus URLs by default. It is recommended to set a `trailingSlash` config (`true` or `false`, not `undefined`).
:::