Looking for a simple way to embed a Github Gist in your WordPress website?
I spent some time reviewing the available plugins in the WordPress plugin repository, so I thought I’d share my findings.
I wanted a plugin that uses WordPress’ native oEmbed support so that I could simply paste the URL to a Gist in my post or page (rather than having to use a special shortcode or another overcomplicated method).
Here’s an screenshot of the plugin in action on one of my recent blog posts:
The plugin allows you to embed any public Github Gist. To do so, just put paste the full URL to the Gist on its own line in your WordPress post or page. For example:
If your Gist contains multiple files, the above example will show all files in the embed.
However if you want to embed an individual file that is part of a multi-file Gist, you use a URL which points to that particular file. For example:
(To obtain that link, view your Gist on the Github website and click the hash link (
#) near that specific file. Then copy the URL and paste it into your WordPress post or page.
It’s that easy!
Using Github Gists (and this plugin) is a great way to embed code snippets in blog posts, because it ensures that the WordPress Visual Editor doesn’t mess with your code.
If you update the Gist, the changes will be automatically visible on your website too.