From 41eaa690ee9013c3faa687d1c268be44950fa632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Tue, 22 Jun 2021 11:25:34 +0200 Subject: [PATCH] docs(v2): GH pages: recommend using trailingSlash (#5033) --- packages/docusaurus/src/commands/deploy.ts | 11 +++++++++++ website/docs/deployment.mdx | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus/src/commands/deploy.ts b/packages/docusaurus/src/commands/deploy.ts index 93ed25a4e9..472524c319 100644 --- a/packages/docusaurus/src/commands/deploy.ts +++ b/packages/docusaurus/src/commands/deploy.ts @@ -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!'); diff --git a/website/docs/deployment.mdx b/website/docs/deployment.mdx index bc8e1e3dfc..06abd6ea39 100644 --- a/website/docs/deployment.mdx +++ b/website/docs/deployment.mdx @@ -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`). :::