Add Code Snippets in your Blog Easily

Whether you use WordPress, Blogger or any other blog, you can be in the situation of wanting to add code snippets on your posts.
There are several ways, and complex plugins you can add.

My favourite tool is GitHub Gist where you add code snippets and you can copy paste the html generated in the form of a <script> into your blog's post. I will be using it to display .NET or Javascript code.



However, and because Html is not something you should be scared of, sometimes I would insert a quick CSS styling into a blog's template Html (usually under settings > template > custom html or similar).

Simply add something like:
immediately before closing the </head> tag, and then when you want to wrap something as a code snippet on your posts, use the Html editor and add it like this:
so that you could see a result like this:
print 'hello world!'

Comments