mathjax + gtag

Pages

Sunday, October 19, 2014

How to post code on Blogger using Gist

The problem

How to post nice pieces of code to a blog? The desired properties are:
  1. Beauty.
  2. Language awareness.
  3. Easy to copy to the clipboard.
  4. Easy to integrate in Blogger.
  5. Easy to maintain

One possible solution

Use Gist.You must have an account on GitHub. Gists are versioned text files, so you can alter them and fix any problems on the Gist page without having to deal with your blog page.

How to integrate it into Blogger

After creating your Gist, copy the "Embed URL" to the clipboard:
The link is something like this:
<script src="https://gist.github.com/mrjimenez/bceea54fdf66a9aec7b2.js"></script>
Reserve a space to integrate the Gist in your blog post. Then choose "HTML" in the Compose/HTML radio button. Insert that code in the proper place in your page, and your're done:


Take a look at the snapshot:


No comments:

Post a Comment