Developergist.github.com

Can you embed GitHub Gist in an iframe?

Yes, but with a script tag, not an iframe. Copy the embed code from the Embed URL box. The page must run JavaScript.

Checked Test again

Live check

What the main page sends

Result of
Gist pageBlocked
gist.github.com/octocat/6cad326836d38bd3a7ae
X-Frame-Options
deny (ignored)
CSP frame-ancestors
'none'
Response
200 OK · 572 ms · HTTPS
Embed scriptNot checked
gist.github.com/{username}/{gist-id}.js

Not checked: needs your own link. GitHub Gist has no public sample we can load.

Test your link

Steps

How to embed GitHub Gist

  1. Open the gist on gist.github.com.
  2. Find the Embed URL at the top of the gist.
  3. Click the clipboard icon next to the Embed URL to copy the embed code.
  4. Paste the embed code into a page or text field that runs JavaScript.
  5. To show one file only, add ?file={filename} to the end of the Embed URL.

A secret gist is not private.

Anyone with the URL can see a secret gist. An embed shows the URL to all visitors of your page.

Embed code

Paste this into your page

HTML
<script src="https://gist.github.com/{username}/{gist-id}.js"></script>

Paste the embed code where the gist must show. The page or text field must run JavaScript.

URL patterns

Swap the link you have for the embed URL

  • You havehttps://gist.github.com/{username}/{gist-id}Use in the iframehttps://gist.github.com/{username}/{gist-id}.js
  • You havehttps://gist.github.com/{username}/{gist-id}Use in the iframehttps://gist.github.com/{username}/{gist-id}.js?file={filename}

Add .js to the gist URL to get the script. Add ?file= to embed one file.

Good to know

  • The embed needs a page or text field that runs JavaScript.
  • GeoJSON files in a gist show as maps in the embed.
  • Public gists show in Discover and in search. Secret gists do not.

Sources

Profile updated

Know before you embed.

Free, no sign-up, nothing stored. Paste a URL and get a verdict, a live preview, and the fix.