Main.css not served from _assets/

Hi, I’m getting a NetWork error when serving the main.css file:

It is supposed to be served from:

/project/asests/main.css

But in the project it is located at:

_site/assets/main.css

Which is the same location as github:

I do not understand if I’m doing something wrong or what.

Thank you.

In the title of your post there is an underline before “assets”. That would cause Jekyll to ignore that folder. Is this really the case?

Yes, it should not have the _ underscore in the title… The point is that in my local project it is under _site/assets (were my main.css is), but on GitHub it is not asking for _assets, just for asset and I guess it should be Jekyll the one who puts everything on is place. Am I worng? I guess so. I’m lost, but do I make sense?

Jekyll puts files where you tell it. If you have a file /assets/main.css then when you build Jekyll will place it at _site/assets/main.css

You have to make sure your layouts or includes are referencing this path as well.

Sorry, I’m lost. I do not remember to tell Jekyll to go to assets/main.css at all. How can i make sure that my layout is referencing that path as well?

It stop working when I created a new domain.

Thanks for your help. I really appreciate it!

Look at the HTML in your _layouts and _includes. Where you specify the style sheet via a <link> element you’ll want to double check that path matches with where you’re saving the style sheet.

Jekyll only does what you tell it to. If you’re paths don’t match or you’re using a different file name it’s not going to load properly.

This is what I see on the index.html (and I change it there and commit):

But the call I see in the Network from the index.html is:

Request URL:
http://www.partidoraro.es/prle/assets/main.css

Why? I’m not saying it is Jekyll, I mean I do not understand it. Thanks

isn’t this a baseurl issue? if you serve from a subfolder rather than the root you need to use baseurl or otherwise prepend the urls with the subfolder name. The css will still be in /assets but by using baseurl you will likely be prepending the subfolder name which should make the path correct.

looks like your baseurl should be /prle

Looks like a baseurl issue to me. Also you have localhost domains in your URLS which if in production is going to cause broken links.

I’m confused why you’re pushing up your compiled _site folder to GitHub Pages instead letting it build your site for you from source files. That could be part of your issue as well with regards to the paths not using baseurl properly.

I guess I was following intructions from here and there, but I did it a few months ago and it was woking fine until I changed the domain. Is there a book or tutorial that explains thing from begining to end? How can I fix it? Or do you know of someone that I can pay to fix this issues and get me up & running smothly?

Thanks you for your help.

Just reset the baseurl in your config file:

- baseurl: "prle" # the subpath of your site, e.g. /blog
+ baseurl: "" # the subpath of your site, e.g. /blog

Thanks a lot, Ashmaroli. It works.

Where was the error? It was working before I changed it to a custom domain (that was the only change). The reason may help others understand it.

Is there anything I can do for you or compensate you for your time? May I get your contact for the next time I get into this kind of trouble.

Thanks again.

When you host on Github Pages, GitHub generates the URL based on your username and repository.name
i.e, if your repository was https://github.com/raroraroraro/raroraroraro.github.io, then all of your assets would be served at https://raroraroraro.github.io/.
But if your repository is at https://github.com/raroraroraro/blog, then GitHub would serve your assets at https://raroraroraro.github.io/blog/.

This discrepancy was eliminated when you moved your site to a custom domain.

More info can be found at https://help.github.com/en/github/working-with-github-pages/creating-a-github-pages-site


P.S. You don’t have to compensate me for the answer above. This is a community forum. We learn and share experiences and knowledge as a service.