Search code examples
githubjekyllgithub-pages

Change baseurl in Jekyll site destroy the CSS


I am a new user of Jekyll and not familiar with web technologies. I create my blog with theses commands. Adding articles and publish them works perfectly. However, when I change the baseurl parameter in the _config.yml broke the CSS website. CSS Broken by baseurl modifications

This is the commands I execute :

git clone mypseudo.github.io (empty repository)
jekyll new mypseudo.github.io
cd mypseudo.github.io
bundle exec jekyll serve
git add --all
git commit -m "Initial commit"
git push origin master

At this step, the blog is perfect. Now I add my files

git add --all
git commit -m "Adding articles"
git push origin master

At this step, blog is perfect

Modification of the _config.yml. Change of the value baseurl: "" to baseurl: "/blog" :

git add _config.yml
git commit -m "Modification of the base URL"
git push origin master

At this step. My blog is broken. Why it's not automatically managed. How can I fix it ?


Solution

  • If your site is hosted at mypseudo.github.io, you must have baseurl: "" in your config.

    If you want to host your site at mypseudo.github.io/blog, you need to version your code in a "blog" repository, and then you set your baseurl:"/blog" to instruct Jekyll to generate valid urls for your ressources.