Writing technical blogs

If you are an author writing technical blogs you know the problems:

  • the rich text editors doesn’t support editing source code very well
  • the most editors doesn’t support tabs (useful for XML)
  • often your formatted sourcecode will be shot

But now we are living in the age of social coding. Since GitHub we are knowing that our code can be forked, commented and reviewed by all users in the internet ;)
But GitHub has another nice feature named GIST. A Gist is a repository containing one or more code snippets. This is versioned like your other sourcecode and every Gist is public and can be used as simple code in your blog posts.

WordPress and Gists

If your are using WordPress as blogging software you can easily integrate your gists. If you search for Gist plugins you will find some: http://wordpress.org/extend/plugins/search.php?q=gist
I am using this one and it works fine. For other blogging software you can embedd your gist with a javascript (see below).

Eclipse and Gists

The current release of Egit (the Eclipse integration of GIT) offers a GitHub integration. And additionally Gists are supported, too. You can add your Gists with Mylyn and attach and remove files to/from your gist.

IntelliJ 11 has Gist support, too.

Working with Gist

There are some steps to do to use gists in your blog:

  1. Login into the Gist area of GitHub (you can use your GitHub account)
  2. Create a new Gist
  3. Add one or more files (code snippets)
  4. Embed this in your blog post:
    [gist id=12345]
    if you have only one file or
    [gist id=12345 file=myfile.txt]
    if you want to specify a file directly
  5. Thats all!

Working with Gist without plugin

You can use your Gists without any plugin, too. It’s quite simple. Add this snippet to your page:

<script src="https://gist.github.com/12345.js?file=myfile.txt"></script>

Comments are closed.