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

Question about # symbol in links #235

Closed
dmytrodanylyk opened this issue Aug 16, 2017 · 5 comments
Closed

Question about # symbol in links #235

dmytrodanylyk opened this issue Aug 16, 2017 · 5 comments
Labels

Comments

@dmytrodanylyk
Copy link

Hi,

Great work with https://docsify.js.org!

I want to migrate my old site to docsify and have two questions:

  1. How I can get rid of # in my urls http://localhost:3000/#/faq? (I want it to be the same as on my old web site e.g. http://localhost:3000/faq
  2. Some urls of my old web site have / symbol at the end. If I try to open http://localhost:3000/#/faq/ it says not found. Is there way to always redirect those links via alias (https://docsify.js.org/#/configuration?id=alias) or there is better way?

Thanks

@QingWei-Li
Copy link
Member

  1. You can change the routing mode to HTML5 History API (https://docsify.js.org/#/configuration?id=router-mode). Because GitHub pages does not support SPA, I can only use hash routing to ensure that the entry file is always /index.html

  2. If the end has / then it will load the /README.md file. I can not think of other ways, except to via alias 😅

@dmytrodanylyk
Copy link
Author

Thanks for the answers. I am planning to use github pages, so looks like I have to use default router-mode.

So how I can redirect users from http://localhost:3000/faq to http://localhost:3000/#/faq? Because if I try to open http://localhost:3000/faq it shows me error Cannot GET /faq

@QingWei-Li
Copy link
Member

QingWei-Li commented Aug 17, 2017

You can create a 404.html and implement route redirection, because we can customize the 404 page in GitHub Pages. But this is not friendly to SEO...

@Jostudy
Copy link

Jostudy commented Apr 24, 2018

Assuming you are using AngularJS ngRoute. Two things I can think of:

  1. in your HTML file: add to the
  2. in your app.js file, where you do configure all the routing. Add
    "$locationProvider.html5Mode(true);"

This way, you don't have the "#", just "http://localhost:3000/faq". Hope it helps.

@bilibiliou
Copy link

You can create a 404.html and implement route redirection, because we can customize the 404 page in GitHub Pages. But this is not friendly to SEO...

yes, u can customize a 404.html, can import a script like this https://www.npmjs.com/package/ghspa
the script will autoly redirect to the page which u wanna visit

caveat, the script was recognized by doccument.title so u should change your 404.html title as ‘404’

u can view the source code of ghspa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants