Search code examples
cssgithubgithub-pages

how to link css files in organization github pages


I'm trying to add an external css file in my index.html.

Organization-name - codehunks

My directory structure is as:

codehunks.github.io
    _layouts/
        style.css
    LICENSE.txt
    README.rst
    index.html

I tried adding it as:

<link rel="stylesheet" type="text/css" href="_layouts/styles.css"/>

but it didn't work. I searched and get to know that raw.github.com/../.. doesn't work in case of css/text

I found some articles adding it by providing link as [username].github.io/[repo]/[folder]/[filname] but this didn't work for my organization.

I tried adding it as codehunks.github.com/codehunks.github.io/_layouts/style.css but the link is giving me 404 not found response.

Any possible solution or I'm following something wrong.

Here's my page codehunks.github.io and here's my code Source Code


Solution

  • your style will work at /styles.css if you put it in the root, _layout folder is used by jekyll/ruby.

    create a css folder in the root of your repo and put the style in there.

    /css/style.css instead.