Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can no longer remove /docs from the URL since v59 #3126

Closed
Dannyholt opened this issue Jul 26, 2020 · 7 comments · Fixed by #3120
Closed

Can no longer remove /docs from the URL since v59 #3126

Dannyholt opened this issue Jul 26, 2020 · 7 comments · Fixed by #3120
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@Dannyholt
Copy link

🐛 Bug Report

Before v59 we were able to remove /docs from the URL by setting routeBasePath: '', whilst still being able to use pages see #2713. However, as of v59 routeBasePath can no longer be empty and adding a / to routeBasePath forces docs-only mode and therefore, no pages. This results in nav items to 404. :(

To Reproduce

  1. Use a landing page.
  2. Add your nav items like this:
items: [
  {
    to: '/getting-started',
    label: 'Getting Started',
    position: 'left',
    activeBasePath: 'getting-started',
  },
  1. Set routeBasePath to '' or '/'
  2. Visit your site and all nav items except the logo will now 404.

Expected behavior

You should be able to remove /docs from the URL without having to use docs-only mode. We really wanted to update so we can use the DocSearch v3, but this is going to prevent us from doing so. :(

Your Environment

  • Docusaurus version used: 2.0.0-alpha.59

Reproducible Demo

N/A

@Dannyholt Dannyholt added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jul 26, 2020
@teikjun
Copy link
Contributor

teikjun commented Jul 27, 2020

Thanks! #3120 adds empty string '' to the list of accepted values for routeBasePath.

@slorber
Copy link
Collaborator

slorber commented Jul 27, 2020

@Dannyholt , as far as I understand, you want docs to be at the root path, yet being able to provide custom pages also under "/".

Actually we had some important refactors on how docs are handled, as they were quite a few bugs, but we should support this usecase and will probably release a fix soon.

Can you confirm this only affect your homepage? or do you see other pages for which this is a problem?


@teikjun this is not related to the '' value specifically, but to this code that removes the homepage in particulary:

    async routesLoaded(routes) {
      const homeDocsRoutes = routes.filter(
        (routeConfig) => routeConfig.path === homePageDocsRoutePath,
      );

      // Remove the route for docs home page if there is a page with the same path (i.e. docs).
      if (homeDocsRoutes.length > 1) {
        const docsHomePageRouteIndex = routes.findIndex(
          (route) =>
            route.component === options.docLayoutComponent &&
            route.path === homePageDocsRoutePath,
        );

        delete routes[docsHomePageRouteIndex!];
      }
    },

Anyway as we already planned to remove that code, it should be fixed for the next release.

@Dannyholt
Copy link
Author

@slorber

I mentioned this in Discord, but thought i'd mention it here anyway. It actually didn't cause any issue with the homepage or other custom pages as they worked as intended. The issue was the nav items in the header no longer worked went to the doc articles and instead caused a 404.

@slorber slorber reopened this Jul 27, 2020
@slorber
Copy link
Collaborator

slorber commented Jul 28, 2020

Hey, this is fixed in #3141

will be released soon, probably tomorrow

@slorber slorber closed this as completed Jul 28, 2020
@slorber
Copy link
Collaborator

slorber commented Jul 29, 2020

released in https://github.com/facebook/docusaurus/releases/tag/v2.0.0-alpha.60

can you tell me if it works?

@Dannyholt
Copy link
Author

@slorber

Yes issue is now resolved. Thanks!

@slorber
Copy link
Collaborator

slorber commented Aug 31, 2020

Hey,

I think accepting '' as a value was a bad idea that actually lead to errors later, but still think that '/' should work for your usecase. Please tell me if you think you can't use '/' instead, because '' will be rejected in alpha 63.

#3375

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants