1

Considering that GitHub gists are no longer anonymous, I have some gists under my GitHub account.

Some of them are actually self-contained html pages, which I would like to serve; as I can see in:

... in the past, apparently https://rawgit.com/ was used for that, but it is now EOL.

So, as the next option, I'd like to serve those gists through GitHub Pages - but I find the setup confusing: for instance, instructions on https://pages.github.com/ say you need to have a repository - and gists are Git repositories, no? But then, when I check them my gists via https://gist.github.com, I cannot see any Settings link.

So, just to confirm: is it possible to serve html files in gists via GitHub Pages - and if not, are there any alternatives that can?

3 Answers 3

0
  • navigate to your gist html file and get the RAWURL by clicking on the RAW button for the file. e.g. https://gist.githubusercontent.com/<username>/<gistnumber>/raw/<morenumbers>/myfilename.html
  • append the RAWURL to https://html-preview.github.io/?url=
  • example: https://html-preview.github.io/?url=https://gist.githubusercontent.com/<username>/<gistnumber>/raw/<morenumbers>/myfilename.html

CAUTION: if this is a secret gist, the URL may expose the content of the secret gist without any authentication. secret gists are not private https://docs.github.com/en/get-started/writing-on-github/editing-and-sharing-content-with-gists/creating-gists

-1

Ok, there seems to be something these days - found via the above stackoverflow post:

https://bl.ocks.org/-/about

Bl.ocks (pronounced “Blocks”) is a simple viewer for sharing code examples hosted on GitHub Gist. For example, if your Gist URL is:

https://gist.github.com/mbostock/1353700

Replace “gist.github.com” with “bl.ocks.org” in the URL to view it:

https://bl.ocks.org/mbostock/1353700

Note that you MUST have an index.html (or README.md) in your gist; otherwise bl.ocks will not. I just added a href local links to my other .html pages in the gist, and that seems to work.

Note that by default, bl.ocks seems to basically render index.html, and then render all other files as source code. But, say you open:

... then there is an "Open" link right below, and that opens up:

... (which in this case, is an empty page); and then you can open up direct via link to a given file:

( this particular example won't work/render, because of "The resource from “https://raw.githubusercontent.com/d3/d3/v1.2.1/d3.js” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff)" - apparently a MIME or redirect problem; however via view source you can see the right HTML ).

Finally, I've noticed, if you use a http://example.com/somelib/somelib.js in your html code in a gist, and you access via https://bl.ocks.org -> then the URL will be rewritten as https://example.com/somelib/somelib.js - which could be a problem, if that example.com site does not serve over HTTPS. Thankfully, you can also call via http://bl.ocks.org - and then unencrypted http URLs don't seem to be rewritten, and the page should work.

Still would be nice to have a definitive answer for Github Pages in this context...

2
  • 1
    Sadly bl.ocks.org doesn't work anymore.
    – Tgr
    Commented Nov 19, 2023 at 3:02
  • You can use gisthostfor.me to do this!
    – cpreid
    Commented Apr 19 at 15:56
-2

I found this service for hosting your gist assets via a CDN.

Your Answer

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

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