Jekyll GitHub Pages no styles applied

I can see my jekyll localhost with styles but they are not applied on gh-pages (in a new project). I:

  • $ jekyll new prle (:>cd prle)

  • $ bundle exec jekyll serve # I get the styles right

  • $ git init

  • $ git checkout -b gh-pages

  • $ git add .

  • $ git commit -am “Initial commit prle”

I create a new repo prle:

But when I check the styles are gone.

Is .gitignore responsible for this?

Thanks for your help

I do not see the solution here: Jekyll website behaves like there is no css file

did you look at the website in the Web Tools of your browser? most likely the console will show that your css is 404. That is because when you have the site as a GH project, the actual site path is as a sub folder of your username. So the path to the css needs to include the project name - it is not /assets/css.

This is what baseurl is for - in the config you can set a value for baseurl that is your project name followed by a slash. Then you can prepend baseurl or siteurl(?) to all your static files to get the correct path.

Some possible problems that are visible in the prle repo:

  • Use of Jekyll 4, rather then 3
  • Jekyll Gem needs to be deleted from Gemfile
  • Missing github-pages Gem in Gemfile
  • Gemfile.lock and _site/ shouldn’t be committed

Consult Github’s instructions for using Jekyll. In particular, steps 7-9 cover the required Jekyll setup: