Using GitHub Gists in the Technical blog posts

Using GitHub Gists in the Technical blog posts

What are GitHub Gists?

Sometimes, you may want to share code that does not require the whole scope of a project, in which case you can create a gist and upload only a few files. In such cases, GitHub Gists are really helpful.

The main advantage is one can comment on your gist. Many a times, people write entire technical blogs using nothing but the GitHub Gists like this one.

And not to forget, one can embed small-small Gists in the technical blogs. (By end of this blog, you will learn to do it on your own.)

Difference between Gist and Repository

Wait… There’s a difference!?!

  1. Gist is a simple way to share small code snippets with others. On the other hand, repository is a place where your entire project codebase and its commit history are stored.

  2. Unlike repository, you can embed a gist in any text field that supports JavaScript, such as a blog post.

Similarities between Gist and Repository

1. Every gist is a Git repository in itself. You can share & collaborate on Gists just like repositories. In short, they can be forked and cloned.

2. Gists can be public or private just like the repository.

3. You can see your repositories in the repository tab in your profile on GitHub. Similarly, you can see your Gists at gist home page.

4. You can pin Gists on your profile like repositories. Learn more here.

How to create Gists?

  1. Sign in to GitHub account.

2. Go to the gist home page.

3. Add filename and appropriate description.

**4. Type the text or attach files in the gist text box.
**You can easily add more files by clicking the add file button.

5. Click the arrow and create a public or private gist.

Adding Gists to your Blog posts

A gist can be embedded in any JavaScript-enabled text field, such as a blog post by following these steps:

A. Get embedded code by clicking the clipboard button next to a gist’s embed URL.

B. Add ?file=FILENAME to the Embed URL.

C. Embed a specific gist file into the blog post’s JavaScript-enabled text field.

Aaand here you go! Now you can use the GitHub Gists to embed code snippets in the blog posts on your personal blog post site.

That’s all for now! See you in the next one.