facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
55.64k stars 8.34k forks source link

baseURL behavior #1081

Closed noraj closed 5 years ago

noraj commented 5 years ago

🐛 Bug Report

I don't know if it is related with #448 but I don't think that baseURL in siteConfig.js has the right behavior or I don't understand it.

I understand that one have to put this config if the documentation is directly accessed under https://rawsec.gitlab.io/':

or to put this configuration if the documentation is accessed from a sub-directory like https://rawsec.gitlab.io/rawsec-cybersecurity-inventory-doc/:

A lot of project behave like that but then they generate the website directly under the build/ directory where Docusaurus is generating it under build/rawsec-cybersecurity-inventory-doc/ creating an extra sub-folder.

So in a CI/CD that auto-deploy the website, if one is doing cp -rT build/rawsec-cybersecurity-inventory-doc/ ../public he will have public/ in the end (we are force to use -T, --no-target-directory or globbing to avoidrawsec-cybersecurity-inventory-doc/ to be copied and resulting in public/rawsec-cybersecurity-inventory-doc/ so the doc would be served under https://rawsec.gitlab.io/rawsec-cybersecurity-inventory-doc/rawsec-cybersecurity-inventory-doc/).

This is forcing us to put rawsec-cybersecurity-inventory-doc/ in the CI file. So if the URL change because the gitlab project/repository is renamed we will have to modify the CI too.

So how I see it is: not creating an extra directory under build/.

I don't really get why the extra directory is created, maybe for people that serve the doc themselves under something like /var/www/html/ so copying build they will already have rawsec-cybersecurity-inventory-doc/ created. But for hosting under Gitlab Pages (maybe same behavior with Github pages and an external CI) this force people to be very careful on how they copy build/.

Of course this won't be a problem for people using publish-gh-pages script. But this is a particular and manual case, where using a CI/CD is a more automated and generic case.

So ok this is a very minor issue, and I maybe should have put it under question. Sorry for the extensive description but this is difficult to explain.

To Reproduce

Don't really applicable. See the description.

Expected behavior

Generated website is directly placed under build/ folder, no extra sub-directory is created.

Actual Behavior

Generated website is placed under build/baseURLhere/ sub-folder.

Reproducible Demo

See the repo: https://gitlab.com/rawsec/rawsec-cybersecurity-inventory-doc

Update: I included the documentation in my current repository instead of having a separate repository: https://gitlab.com/rawsec/rawsec-cybersecurity-list/

noraj commented 5 years ago

PS : please take a look at my .gitlab-CI and also give an example for GitLab under https://docusaurus.io/docs/en/publishing.

noraj commented 5 years ago

erratum : I just figured that was projectName that was used and not baseURL to create the extra sub-folder.

yangshun commented 5 years ago

I agree. This is a legacy decision that we'll fix in v2.

noraj commented 5 years ago

@yangshun Nice to hear.