Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does GitHub Pages have a shortcut way of linking to files in its git repository?

I have a git repository with a bunch of code at https://github.com/ozzyogkush/solitaire-webapp, and a GitHub pages branch (at https://github.com/ozzyogkush/solitaire-webapp/tree/gh-pages) all set up for that repository. The question is, does GitHub pages (when rendered at http://ozzyogkush.github.io/solitaire-webapp/) 'see' the main repository in any way? Meaning if I want to include a stylesheet (say, stored in {repository}/somedir/css/somecss.css), is there a shortcut way of doing it (that also sends the correct MIME type) or do I have to link to the full raw data URL?

If you look at the source of the GH Pages you'll see I'm grabbing some CSS and JS from the repo, using the full path to the raw source, and both of them are returned in plain text rather than text/css and application/javascript as expected.

like image 468
Derek Avatar asked Jul 31 '14 11:07

Derek


People also ask

How do I link to a file in GitHub?

Linking to code On GitHub.com, navigate to the main page of the repository. Locate the code you'd like to link to: To link to code from a file, navigate to the file. To link to code from a pull request, navigate to the pull request and click Files changed.


1 Answers

Github raw url like https://raw.githubusercontent.com/ozzyogkush/solitaire-webapp/master/prodbuild/css/bootstrap.css will always return a text/plain mime.

Some Stack Overflow answers are talking about services like https://rawgithub.com/ that returns the right mime for both css and javascript. But they are out of control and can be a real security problem because you have to trust them to send the original content. Not an option for me.

This answer with a post commit hook that sends your modified assets from master to gh-pages seems to be a good solution.

You can also look on the side of mixing Grunt with Jekyll and keep all you code on the same branch.

like image 53
David Jacquel Avatar answered Nov 15 '22 05:11

David Jacquel