Referencing a .css file in github repo as stylesheet in a .html file

前端 未结 5 681
感情败类
感情败类 2020-12-01 06:17

I\'ve got a repository on github with a .css file in it. Is there any way to have github serve this file in a way that I can consume it in a web page?

In other words

相关标签:
5条回答
  • 2020-12-01 06:55

    Check out https://gitcdn.link/ . Seems to work well.

    Rawgit.com has shut down.

    0 讨论(0)
  • 2020-12-01 06:57

    Important: rawgit.com is shutting down. Read more about other alternatives here - https://rawgit.com/


    Found something really cool. You get the raw link as: http://raw.github.com/...

    Simply fetch the files from rawgit.com (or cdn.rawgit.com) instead of raw.github.com and DONE!


    UPDATE:

    You can also use raw.githack.com if you want to serves raw files directly from Bitbucket or GitLab

    0 讨论(0)
  • 2020-12-01 06:58

    GitHub repos aren't web hosting, you should push that stuff up to a service specifically designed to serve files, like pages.github.com.

    0 讨论(0)
  • 2020-12-01 07:02

    You have to use RawGit which, is a part of MaxCDN, serve files directly from the GitHub repository with the correct content type header. Full tutorial, click here

    0 讨论(0)
  • 2020-12-01 07:03
    • First Visit RawGit as suggested earlier
    • Next copy your file path from github into the RawGit box
    • RawGit will automatically produce two refrences to your web page
    • The Development and Production refrence
    • refrence the development link in your webpage if you are still developing
    • save/upload then reload your webpage
    • if there was no change it means your browser has saved your former refrence
    • clear your browser data then reload
    • Hope that helps?
    0 讨论(0)
提交回复
热议问题