Monday, July 4, 2011

Posting code snippets to Blogger

In my last post I wanted to put some Java and JavaScript code snippets in it so I started googling and asking my friends how to do it. But, I could not find an easy way to do that so I started searching more and found the following which is actually a zero work thing to do. Here we go,

  1. Browse to
  2. Add a Gist Description (optional)
  3. Add a filename with an extension (extension will be used to add syntax highlighting)
  4. Add your code snippet which need to be added to your blog post
  5. Click “Create Public Gist” button at the botton
  6. Click on the “embed” link and copy the script generated
This is all from Gist side. Now to Blogger,

     7. Paste the script where you need to add the code snippet
     8. Make sure to select the option “Interpret typed HTML” under Post Options -> Compose Settings

Here is how an example Java code looks like after this 8 Steps above,

Publish your post and enjoy! 


  1. Thanks mate. Helped me in a quick set-up.

  2. its worked for me at

    thanks a lot

  3. Thank you for this tip. I had been looking all around for a simple solution like this.

  4. gist is beautiful, I checked some other option and wrote about it:

  5. Thanks Kasun. Just a note, the embedding code won't work for "Dynamic View" templates.

  6. I do not see "option “Interpret typed HTML” under Post Options -> Compose Settings".
    Is it removed or changed ?

    1. seems it's now here if not I think it depends on the theme you are using.

  7. algolint is best online website dealing with all kind of online complier and online ide.. code snipets and compile and execute program online can be access and an be deal with no issue and erros free

  8. Great tutorial this really helps specially I'm applying for a web development company in the Philippines

  9. This comment has been removed by the author.

  10. Snippets are almost giving the true values which will make easy task to remember in your mind the posting codes and such kind of the various values. java homework

  11. ya. but we can't depend fully on Gist for every single code we wanna write. Some statements may be a word or two. Adding a gist for such a statement is really inefficient.

  12. There are many available tools by which you can highlight your java programming code here. I also use your trick to publish my Java Homework.

  13. Thank you, Kasun! Your blog is super helpful! I find pretty useful this site for doing homeowrk as well: Java assignment help. Happy coding everyone!