saagarjha
saagarjha

Reputation: 2320

Using a custom base URL for project pages

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?

Upvotes: 3

Views: 1747

Answers (1)

VonC
VonC

Reputation: 1328972

That should be what baseurl is for.

https://byparker.com/img/what-is-a-baseurl.jpg

  • 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!

Upvotes: 4

Related Questions