diff --git a/gatsby-node.js b/gatsby-node.js index 3abded6b..89fc1db8 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -124,11 +124,16 @@ exports.createPages = async ({graphql, boundActionCreators}) => { process.exit(1); } + // A leading "/" is required for redirects to work, + // But multiple leading "/" will break redirects. + // For more context see github.com/reactjs/reactjs.org/pull/194 + const toPath = slug.startsWith('/') ? slug : `/${slug}`; + redirectToSlugMap[fromPath] = slug; createRedirect({ fromPath: `/${fromPath}`, redirectInBrowser: true, - toPath: `/${slug}`, + toPath, }); }); }