2

I have a GitHub project with a CSS file and I want a HTML page to be able to pull this in so I created a GitHub pages branch and synced everything over.

The file is included as such:

<link href="https://raw.github.com/dublintech/JavaScript_Examples/gh-pages/jsquiz/css/jquiz.css" type="text/css" rel="stylesheet">

But in Firebug I am getting the following error:

The stylesheet https://raw.github.com/dublintech/JavaScript_Examples/gh-pages/jsquiz/css/jquiz.css was not loaded because its MIME type, "text/plain", is not "text/css".

So I still get wrong MIME type. Any ideas what I am doing wrong?

1 Answer 1

5

This is by design as you should not be serving or linking to raw files in this manner.

It could also be seen as abuse of their services as linking to the raw file is using GitHub as a content delivery network (CDN).

Instead, you need to make use of the GitHub Pages feature and link to the file from there. Which, when you build your pages will be along the lines of:

<link rel="stylesheet" href="http://repo-owner.github.com/repo/css/style.css">

In your case, it would be here:

<link rel="stylesheet" href="http://dublintech.github.com/JavaScript_Examples/jsquiz/css/jquiz.css">

And when it is referenced from the correct location, it will be served as text/css as expected/wanted.

3
  • This is a better way as it does prevent link rotting, though you have to manually update it if the original copy is changed on the master branch on the repository.
    – Hydra
    Jan 28, 2013 at 10:01
  • Another option is to just get rid of the master and work solely from the gh-pages branch - oli.jp/2011/github-pages-workflow
    – Mottie
    Nov 25, 2013 at 21:03
  • it is github.io rather than github.com no?
    – jangorecki
    2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.