Jacob Price
Jacob Price

Reputation: 71

gh-pages won't load CSS or JS

Alright, so I have Jekyll running my site locally and it runs perfectly fine. When I pushed everything to Github and made it a gh-page all styling and js functions disappeared. When I go onto the site I see that the css files that it is pointing to are empty, though they clearly have styling in github... So i've tried several of the solutions that I could see on here, but to no avail. This is the gh-page currently: https://jacobprice.github.io/Webpage/

The code is here: https://github.com/JacobPrice/Webpage

I've been changing stuff around based off solutions here, so hopefully I haven't broken something else... Any help is greatly appreciated.

Note** if the site is down it will show an old ruby on rails project with a countdown. That is not the gh-page site.

Upvotes: 1

Views: 3499

Answers (3)

Jacob Price
Jacob Price

Reputation: 71

Okay, so this is kind of a work around... Not sure why it wasn't directing to the proper folder, but the fix for me was to copy my main.css (the full css that sass compiles) and then create another main.css file where it kept pointing too. Kind of a hack and not proper, but it works...

Upvotes: 1

David Jacquel
David Jacquel

Reputation: 52809

In _config.yml, set baseurl: /Webpage and call your resources like this :

<script src="{{ site.baseurl }}/assets/js/jquery-2.1.1.min.js"></script>

It will now work both locally and on gh pages.

Upvotes: 0

Văn Tuấn Phạm
Văn Tuấn Phạm

Reputation: 659

View page source your website.

I see your url failed

Edit Your Url load css and js file:

<link rel="stylesheet" href="/assets/css/main.css" />
<script src="/assets/js/jquery-2.1.1.min.js"></script>

<script src="/assets/js/functions.js" type="text/javascript"></script>

You should use relative path for url

Upvotes: 1

Related Questions