10

I can't get my CSS to show on the site. I really can't figure out what I'm doing wrong here, I'm very new to all of this so I'm sure there's something I just can't see.

here is the live site https://rusne118.github.io/mile-stone-one/4

here is my repo https://github.com/rusne118/mile-stone-one

here is my css in my html

here is my files on cloud9

Dharman
  • 30,962
  • 25
  • 85
  • 135
rusne
  • 161
  • 1
  • 2
  • 5

5 Answers5

29

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">
Tomasz Błachut
  • 2,368
  • 1
  • 16
  • 23
  • 4
    Assigning a custom domain would also resolve this, i.e. `https://mile-stone-one.io/css/style.css` – crizCraig May 17 '19 at 20:18
  • A little more context for newbies like myself: from the commandline I had to run `bundle info --path minima` because i'm using the minima theme. Then I had to open the theme in VSCode and edit the header listed in the `_includes` directory to match the top answer. – J.R. Bob Dobbs Dec 28 '22 at 02:43
9

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/

  • 2
    This is was our problem as well. Thanks! Sorry to be pedantic, but it is "Sphinx" not "Sphynx". – Michael May 04 '21 at 13:22
  • Oh, I've fixed that typo, thanks. – Gábor Kiss-Vámosi May 05 '21 at 14:20
  • This worked for me, instead of a) rechecking css paths, b) resetting the cache -- directly access the url with a hard refresh, c) try waiting couple more hours. Anyone who is sure they have the right path (check source and dev tools) and can confirm it's not the client's fault, ought to try this out. – Jang-hwan Kim Mar 15 '22 at 00:26
6

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.

5

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.

Shreyas Shetty
  • 618
  • 6
  • 13
0

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.

tripp101
  • 9
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 01 '21 at 14:53