Is it possible to serve gist HTML files via GitHub Pages (or elsewhere)

githubgithub-pages

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?

Best Answer

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...