I’ve only recently discovered Jekyll, and I’m really excited by the prospect of learning more about it. I’ve been following a tutorial on how to build a basic site, and in the final step I pushed the folder to GitHub and tried to set up a GitHub Pages site to see the basic build/theme etc. Unfortunately, for some reason, when I view the site on GitHub Pages it doesn’t seem to be loading any of the stylesheets, even though they appear to be in the repository. Has anyone come across this problem before and could shed some light on the issue?
Don’t push up the compiled
When hosting on GH it’ll build the
_site folder for you. So there’s no need to commit it. By pushing it up it’s overwriting what GH generates which is why your stylesheets aren’t working.
If you look at the HTML files in
_site all of the asset paths are
http://localhost which obviously isn’t going to work on GH. Removing this folder should clear things up for you.
isn’t that what the .gitignore file is for? there’s a line in there where it says it will ignore the _site folder. i’m not sure how to push only selected folders, but thanks for setting me on the right track.
Yes that’s what
.gitignore is for, but depending on when you committed
_site it might not have taken affect.
You’ll probably have to remove the
_site line from
.gitignore and commit that change. Then you can remove
_site folder, commit that, then add
_site back to your ignore.
Otherwise git won’t track that you’re removing that folder from the repo.
OK great, I will try that - thanks! Also one more query though if you don’t mind:
If I remove the
_site folder locally, won’t it just get made again when I run
jekyll build? Then I’ll have the same problem when I commit again? Sorry if this seems obvious.
Yes that’s correct. If you have your
.gitignore setup properly in your repo
_site/ will live in your local environment only, not in the git repo pushed up to GitHub.
You don’t want to see
/_site in your
gh-pages branch up on GitHub.
Only other thing you have to do after that is set
baseurl properly since you’re using GH Pages as a project.
That should give you the correct paths to your CSS and other assets.
OK great, thanks so much for your help - much appreciated