Docusaurus: Improve support for trailing slashes

Created on 24 Apr 2020  路  5Comments  路  Source: facebook/docusaurus

馃殌 Feature

Add a preferTrailingSlashes option (or something similar) to docusaurus.config.js.

Have you read the Contributing Guidelines on issues?

Yes.

Motivation

If hosting documentation on GitHub Pages, a trailing slash appears in the URL when navigating to a specific Docusaurus page from outside the docs.

For instance, https://glaze.js.org/docs/introduction sends the visitor to https://glaze.js.org/docs/introduction/.

In order to keep consistency, there should be an option for sidebar links to have a trailing comma by default, without resorting to a longer sidebar item format.

feature

Most helpful comment

I think we should take a stance here and add trailing / to all Docusaurus-generated URLs. This will bridge the differences during development and deployed. cc @lex111 @slorber

All 5 comments

I've noticed that the trailing slash potentially destroys internal links as well since the relative root is different. Don't know if this is a separate bug or a side effect.

@davidhagg Same here. I'm deploying to GH Pages (v2, latest alpha). It seems like it adds / always to all pages, so relative links are broken :(

This also breaks Azure Front Door routes. I migrated a Docusaurus + GitHub Pages site to Azure Web Apps behind an Azure Front Door and all site pages without a trailing / redirect by Front Door presumably correctly, but the Docusaurus compiled application routes to a / and when it does this is referrer is the backend server name not the custom domain name with the URL and trailing / appended.

It appears, also there may be something deployed in the root that does dynamic routing, otherwise, I'd expect Docusaurus compiler to simply create all URL paths with / or without.

I like this feature request and hope it addresses my issue as well.

I think we should take a stance here and add trailing / to all Docusaurus-generated URLs. This will bridge the differences during development and deployed. cc @lex111 @slorber

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nebrelbug picture nebrelbug  路  3Comments

awibox picture awibox  路  3Comments

sebqq picture sebqq  路  3Comments

MoogyG picture MoogyG  路  3Comments

ericnakagawa picture ericnakagawa  路  3Comments