I am developing a static site using Jekyll
, to be deployed on github pages
. I am facing issues using the baseurl in the configuration file. Here is an extract of my _config.yml
:
baseurl: "/blog"
url: "http://remidoolaeghe.github.io"
When ran locally at http://localhost:4000/blog/, everything is fine. The html pages are found, the resources (images, css, js) are loaded and applied on the pages.
Once deployed on Github Pages
, I would expect to have the site available at: http://remidoolaeghe.github.io/blog
But the actual URL is http://remidoolaeghe.github.io.
It seems the baseurl is not used by the Jekyll
on Github Pages
. The HTML pages are not at the expected URLs, neither any resources is (css, images, etc). Nothing based on baseurl is loaded by the browser, as you can see here:
I have checked the used Jekyll version
. I use the same as Github Pages
(2.4.0).
Have I missed something?
My Github
repo can be found here.
Another alternative to redirecting to /blog
is:
1. GitHub Pages Redirect from
GitHub pages allow for the redirect-from
Jekyll plugin as mentioned here. You could use their plugin and redirect from there. Although as it's built for preventing old links from going to 404, this might not be what you want given your use-case.
2. Manually have meta refresh tag in your root index.html
.
<META http-equiv="refresh" content="0;URL=/blog/">
You'll want that tag in a <head> </head>
. This will tell the any request to your root url point to the index.html
stored at /blog/
. This is a fast way to doing it, similar to how .htaccess
rewrites are done, except GitHub Pages doesn't support .htaccess for security reasons. At that point also check if you're getting 404
s for some resources and update their paths accordingly, maybe with the help of site.baseurl
, as another answer explains. baseurl
is not what you think it does. See this post by Parker about the baseurl variable.
In short,
I think your best option is to use the second one, short of creating a gh-pages blog
repository and moving your site there. In fact, if you did move to a a separate blog repo which might make things complicated, you still need to redirect http://remidoolaeghe.github.io
to point to http://remidoolaeghe.github.io/blog
or else people who visit http://remidoolaeghe.github.io
and not the /blog
link get a blank page only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With