css not working on github pages

Viewed 28979
5 Answers

Remember that GitHub pages are scoped with repo names.

You are including your CSS with

<link rel="stylesheet" href="/css/style.css">

This resolves to https://rusne118.github.io/css/style.css

but you want https://rusne118.github.io/mile-stone-one/css/style.css

Simply change link tag to

<link rel="stylesheet" href="/mile-stone-one/css/style.css">

I had this problem and instead of doing:

<link rel="stylesheet" href="/css/style.css" />

I did:

<link rel="stylesheet" href="css/style.css" />

(without the first '/') And it worked fine.

For us, the solution was to add an empty .nojekyll file to the root of the repo.

We used Sphinx to generate the site which places CSS in _static/css folder.

Explanation:

It is now possible to completely bypass Jekyll processing on GitHub Pages by creating a file named .nojekyll in the root of your pages repo and pushing it to GitHub. This should only be necessary if your site uses files or directories that start with underscores since Jekyll considers these to be special resources and does not copy them to the final site.

Source: https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/

Adding type="text/css" to <link rel="stylesheet" href="style.css"> worked for me.

So finally it looked like <link rel="stylesheet" type="text/css" href="style.css">

In this case , the HTML file and the CSS file are located in the same folder.

In my opinion, it just takes time man, a lot of time. Try, changing to another branch(maybe none) and save. Later change back to your main branch and save. Well worked for me but yeah took some time.

Related