Search code examples
docusaurus

making it so docusaurus uploads to subdirectory instead of web root


From node_modules\docusaurus\lib\publish-gh-pages.js:

      const websiteURL =
        GITHUB_HOST === GITHUB_DOMAIN
          ? `https://${ORGANIZATION_NAME}.github.io/${PROJECT_NAME}` // gh-pages hosted repo
          : `https://${GITHUB_HOST}/pages/${ORGANIZATION_NAME}/${PROJECT_NAME}`; // GitHub enterprise hosting.

My question is... why is the documentation being uploaded to a subdirectory? What if I wanted it uploaded to the root directory? How might I do that?

The front page of a docusaurus v1 website is more of a splash page with sections like "feature callouts", etc. Overall, it seems best suited to be a root page as it appears to be for https://hermesengine.dev/ , https://hydra.cc/ and pretty much every other facebook open source project.

Also, the HTML that docusaurus generates has <link rel="stylesheet" href="/css/main.css"/> in it, which works great when you're building your site with npm run start (which results in the files living in web root), but not so much when using publish-gh-pages.js since main.css then lives at /${PROJECT_NAME}/css/main.css.

So how can I do the same - make it so my docusaurus built website gets uploaded to web root instead of a subdirectory?


Solution

  • The repo was that the repo wasn't named project_name.github.io - it was named docs. That this would result in docusaurus doing the build process is evident from the build script BUT apparently github.com itself will default to a subdirectory for github.io unless your repo name is project_name.github.io. This can be seen by scrolling to the bottom of the page that Settings brings up.