Introduction
You want to display, embed or share code snippets in your posts? Github Gists could be an excellent solution addressing this situation.
Imagine this: You have a code snippet which you want to repeatedly use in your posts. Usually, the code snippet would be a part of the post itself. Now, if you need to make a change to that code snippet, then you will have to update all those posts in which you have pasted the snippet. Very soon, this will be come a real pain, if you understand what I mean.
A much better way of handling such a situation is to make use of Github Gists and then embed them in your posts instead of pasting them. If your code is embedded, you just need to make the change once and all posts with the embedded code would be updated automatically.
What are Github Gists?
With gists, you can share single files, parts of files, and full applications with other people. -Github Help
There are two types of Gists. Public and Secret. If a gist is public, you can’t convert it later to a secret gist. Secret Gists would be accessible only by your or with those who you share the link with of the secret gist.
You can access, create and discover gists by doing the following:
- Login to your Github Account (or create one if you don’t have one)
- From the navigation on the top right select Your Gists or head over to https://gists.github.com
- You will be led to the overview page of your gists (if you have any) or you’ll be directly forwarded to the create gists page
- Give your gist an optional description
- Enter the Filename for your gist
- At the bottom, decide if you want it to be a public or secret gist
- Done
How to embed & display Github Gists in WordPress?
In short, there are two ways of doing it. With Plugin and without Plugin.
Without Plugin
Just like YouTube or other major websites, Github gives you an option to copy and paste the embed code.

- Open your own Gists or any other gist
- Copy the embed code as shown in the screenshot above
- Paste into WordPress Editor
- Done
With Plugin
If you don’t like to copy paste the embed code, there is a handy plugin developed by
called oEmbed Gist. With the Plugin, you can- Embed your source from gist into WordPress easily
- You simply have to paste the URL of your Gist
- You can embed a specific revision of the Gist
- You can embed an individual file that is part of a multi-file Gist
As mentioned above, you just would have to paste the URL and not the whole embed code into the WordPress Editor and the rest is history.
Head over to the WordPress Plugin Directory and download oEmbed Gist and give it a shot.