Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css not working on github pages [closed]

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

like image 531
rusne Avatar asked Aug 24 '18 10:08

rusne


People also ask

Why is my css code not working?

If you put the <link> tag inside another valid header tag like <title> or <script> tag, then the CSS won't work. The external style CAN be put inside the <body> tag, although it's recommended to put it in the <head> tag to load the style before the page content.

Can you use css in GitHub?

You need to link your HTML to the github page rendered style. css and not the file itself in the repo. And move that stylesheet reference inside your <head> tag.

Is GitHub Pages static only?

GitHub Pages publishes any static files that you push to your repository. You can create your own static files or use a static site generator to build your site for you. You can also customize your own build process locally or on another server.

Why my GitHub Pages is not working?

Solution: Verify the publishing source and published URL from your repository's settings tab. Double check that you are using the correct URL by visiting your repository's Settings, and scrolling down to the GitHub Pages section. You should see the URL where your site is published.


2 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">
like image 81
Tomasz Błachut Avatar answered Oct 18 '22 07:10

Tomasz Błachut


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/

like image 45
Gábor Kiss-Vámosi Avatar answered Oct 18 '22 08:10

Gábor Kiss-Vámosi