question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation-only sites do not work if baseUrl is not `/`

See original GitHub issue

🐛 Bug Report

A docusaurus site (v2) without a landing page and documentation as the index page does not work if baseUrl is other than /.

It seems like @docusarus-utils.normalizeUrl is generating double forward slashes when routeBasePath is set to a single ‘/’ in the docs plugin configuration.

For a baseUrl: 'metro/' and docs.routeBasePath: '/' the generated routes are:

...
/metro//2.0.0-alpha.43/using-plugins
/metro//2.0.0-alpha.43/using-themes
/metro//2.0.0-alpha.43/versioning
/metro//next/blog
/metro//next/cli
/metro//next/configuration
/metro//next/contributing
/metro//next/creating-pages
...

When navigating to /metro/next/blog, react-router finds no match and the “Page not found” message is loaded instead.

Have you read the Contributing Guidelines on issues?

Yes.

To Reproduce

Using docusaurus’ website/ in the repository as an example:

  1. Set baseUrl to /metro/ in your docusaurus.config.js.
  2. Set routeBasePath to / in the @docusaurus/preset-classic.docs section of your docusaurus.config.js.
  3. Run yarn start
  4. Navigate to https://localhost:3000/metro/introduction
  5. "Page not found: is displayed.

Expected behavior

https://localhost:3000/metro/introduction should have loaded the Introduction page (in docs/introduction.md), just like https://localhost:3000/docs/introduction loads it when baseUrl and routeBasePath have their default values.

Your Environment

  • Docusaurus version used: 2.0.0-alpha.48
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node.js v10.19.0
  • Operating system and version (desktop or mobile): MacOS X Catalina 10.15.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
joe-bellcommented, Jun 7, 2021

Thanks for the quick response @slorber – moving the directory certainly seems to do the trick for now

In the meantime, I’ll stick with:

docusaurus build --out-dir build/docs
1reaction
slorbercommented, Jun 7, 2021

@joe-bell this is a bug: https://github.com/facebook/docusaurus/issues/3291

To fix it locally you could probably move build to build/docs and run docusaurus serve again

Read more comments on GitHub >

github_iconTop Results From Across the Web

[SOLVED] Site based on official Hugo documentation layout ...
When I run hugo the generated pages in the public folder does not reference css style sheets etc correctly, the base_url is not...
Read more >
Diagnosing base URL configuration problems
If your instance's base URL is not configured properly, the UPM will display a warning informing you that the base URL of your...
Read more >
Absolute Links from Subfolder Do Not Respect BaseURL ...
Inside index.md , I have the following link: [Link Text](/folder/index.md) . This correctly get converted to an HTML link pointing to /< ...
Read more >
Jekyll's site.url and baseurl - Made Mistakes
Learn what Jekyll's site url and baseurl variables are and how to properly set them with relative_url and absolute_url filters to avoid ...
Read more >
The Document Base URL element - HTML - MDN Web Docs
A document's used base URL can be accessed by scripts with Node.baseURI . If the document has no <base> elements, then baseURI defaults...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found