CSS file from GitHub pages sent as text/plain, needs to be text/css

cssgithub

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?

Best Answer

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.