-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Enable clean / extension-less url #677
Conversation
Deploy preview for docusaurus-preview ready! Built with commit 52376f0 |
6abeda5
to
b36f0ac
Compare
004d141
to
63d4982
Compare
This is a neat feature. Thanks for supporting the old urls as well! |
Just tried this out myself while I was testing the other non-related issue! Great work! |
I am not in a rush with this PR, i'm out of reach from my laptop until this weekend because i'm currently hospitalized. But i have tested it on dev & prod build in local web server before and there is no problem yet. But note that custom pages (e.g: pages/en/index.js) with hardcoded link still link to docs/installation.html Do we want to change it to extension-less one ? |
Hi @endiliey
Best wishes to you. 🙏
We can change those in a separate PR, I think. |
I am ready anytime. I'll leave it to your decision. Waiting for @yangshun approval is also a good idea 😉 |
I'll give it a thorough look tonight! One concern I have is that will the blog comments will show different contents depending on whether it's the index.html version or the clean URL version? Not sure if FB treats them as canonical URLs. |
I just tested that and it is actually the same url. Regardless of I just added 'Wow, awesome' to one of the blog comment in netlify preview and you can see it in all three url ☺ https://deploy-preview-677--docusaurus-preview.netlify.com/blog/2017/12/14/introducing-docusaurus/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks!
One suggestion. And we can get a second stamp from @yangshun.
docs/api-site-config.md
Outdated
@@ -167,6 +167,8 @@ h1 { | |||
|
|||
`wrapPagesHTML` - Boolean flag to indicate whether `html` files in `/pages` should be wrapped with Docusaurus site styles, header and footer. This feature is experimental and relies on the files being `html` fragments instead of complete pages. It inserts the contents of your `html` file with no extra processing. Defaults to `false`. | |||
|
|||
`cleanUrl` - If `true`, allow URLs with no `html` extension. Example: request to URL https://docusaurus.io/docs/installation will returns the same result as https://docusaurus.io/docs/installation.html. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this up to be alphabetical with the rest of the optional fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can. But i'm out of reach from my pc until this weekend. I'll do it later if you don't mind. Sorry!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - no worries. I can do it for you 👍
PR updated. Rebased on top of 1.1.5 Not sure if we want to remove the hardcoded linking values in Docusaurus custom pages if this is merged. Example: |
@endiliey Could we try to come up with a way to reduce the amount of duplication in the code? |
@yangshun refactor done ! Sorry for the wait. I've tested this on Windows as well. |
Let's do this! |
Motivation
Closes #413
This is a feature request in issue #413, and #478 (comment)
Some of Docosaurus URL look very cryptic/un-clean. Instead of
blog/a.html
,blog/b.html
, andblog/c.html
, user should be able to choose if they prefer to seeblog/a
,blog/b
andblog/c
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
cleanUrl
insiteConfig.js
,If
true
, all linking from each page will be without.html
except custom pages that has hardcoded linking value.Before:
After:
yarn start
will allow extension-less url (server routing)Which means request to
docs/a.html
is the same asdocs/a
Test
yarn start
server routing on development serverhttp://localhost:3000/docs/en/installation
http://localhost:3000/docs/en/installation.html
yarn build
will generate extra file whencleanUrl
atsiteConfig.js
is trueTest
yarn build
to see generated filesResults are expected
Full generated files structure can be seen at https://gist.github.com/endiliey/cd184c237bc1c0b544677ad19cc8ece7
http://localhost:5000/docs/en/site-preparation
http://localhost:5000/docs/en/site-preparation.html
http://localhost:5000/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus
http://localhost:5000/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus.html
http://localhost:5000/en/about-slash
http://localhost:5000/en/about-slash.html
All seems to be working fine. Every url is accessible with and without .html
Alternatively, you can test production build in Netlify
https://deploy-preview-677--docusaurus-preview.netlify.com/