Using a custom base URL for project pages

家住魔仙堡 提交于 2019-12-08 03:57:50

问题


I'm using Github pages/Jekyll for both my personal page as well as my project page.
I'm also using a custom domain, so something like username.github.io redirects to mycustomdomain.com.

Since I also have a gh-pages branch for my projects, my project's page lives at mycustomdomain.com/myproject.

However, I'd prefer if I could choose what this URL would be, for example, mycustomdomain.com/projects/myproject.

Is there any way to do this, without copy/pasting the whole project my username.github.io repository's projects folder?


回答1:


That should be what baseurl is for.

  • Set baseurl in your _config.yml to match the production URL without the host (e.g. /example, not http://jekyll.github.io/example).
  • Run jekyll serve and go to http://localhost:4000/your_baseurl/, replacing your_baseurl with whatever you set baseurl to in your _config.yml, and not forgetting the trailing slash.
  • Make sure everything works.
    Feel free to prepend your urls with site.baseurl.
  • Push up to your host and see that everything works there, too!


来源:https://stackoverflow.com/questions/40567511/using-a-custom-base-url-for-project-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!