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
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}.jsNot checked: needs your own link. GitHub Gist has no public sample we can load.
Test your linkSteps
How to embed GitHub Gist
- Open the gist on gist.github.com.
- Find the Embed URL at the top of the gist.
- Click the clipboard icon next to the Embed URL to copy the embed code.
- Paste the embed code into a page or text field that runs JavaScript.
- 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
- GitHub Docs · Creating gistsdocs.github.com/en/get-started/writing-on-github/editing-and-sharing-content-with-gists/creating-gists
- MDN · X-Frame-Optionsdeveloper.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Frame-Options
- MDN · CSP frame-ancestorsdeveloper.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/frame-ancestors
- iframecheck live check · main page
Profile updated