How to link index.html file with css for github page

I host the github page and want to link index.html to main.css, which is located in a folder called "stylesheets" also in the root directory.

my file structure:

index.html stylesheets - main.css 

right now i have:

 <link type="text/css" rel="stylesheet" href="/stylesheets/main.css" /> 

in <head> , but that doesn't work?

+6
source share
3 answers

First, you must create the gh-pages branch, a special GitHub branch.
You can find and create it on the settings page of your project using the button Automatic page generator .
The branch will be displayed on doamin http://username.imtqy.com/project/

So the path should be stylesheets/main.css not /stylesheets/main.css

+5
source

if these are not project pages .. "means" that you are creating repo youruser.imtqy.com (username pointer .imtqy.com) not atuo genereate gh-pages, because its usage pattern

just:

  • clone it
  • create and go to gh-pages branches
  • commit and click it

    /style β†’ you are in the root directory
    style/ β†’ you are in the currrent directory
    ./style β†’ it’s safer to navigate the current directory

Wait 5 minutes ... and cheers!

+1
source

Try removing the front '/' from /stylesheet so that it loads relative to the current route: stylesheet/...

-1
source

All Articles