Sunday, February 28, 2010

How to add "Tweet This" button to your Blogger Posts

Twitter has become one of the most popular ever syndication and networking tools for bloggers. A few readers have asked if it is possible to add a "Tweet This" link to our Blogger templates, and while this was possible, I had not discovered a method of automatically shortening the URL of our blog posts until now.

In this tutorial, I'll explain how you can add this to your Blogger template so your readers can Tweet your posts to their Twitter followers, enabling your Blogger posts to be syndicated to a wider audience.

Editing your template to add the Twitter links

First of all, you should make a full back-up of your existing template (which you can later restore if you make a mistake in the coding). To do this, go to Layout>Edit HTML in your Blogger dashboard and click on the "Download full template" link near the top of the page. Save your template to a location on your computer which you can easily access later.

Next, go back to the Layout>Edit HTML page and ensure you have checked the "Expand widget templates" box. The place where we need to add the Twitter code is contained within the Blog Posts widget.

Search for this section in your Blogger template code (or similar):

<div class='post-footer-line post-footer-line-1'>

If you cannot find this exact line of code, search for 'post-footer' instead. Alternatively, you can add your code immediately after the <p><data:post.body/></p> line.

Just after the 'post-footer' line you have located, paste the following section of code:
<script type="text/javascript" src="http://ajax.twitthis.com/chuug.twitthis.scripts/twitthis.js"></script>
<script type="text/javascript">
document.write('<a href="javascript:;" onclick="TwitThis.pop();"><img src="http://howtogetrichandstay.com/images/twitthis_grey_72x22.gif" alt="TwitThis" style="border:none;" /></a>');
</script>
Preview the changes to your blog template to make sure you have not made any errors in adding the code. If all is well, the preview page should load (though you will ne unable to see the Twitter link on the preview page).

Finally you can save your template. Now when you view an item page on your blog, you will see a link in the post-footer section which looks like this:

 

I hope you will enjoy using this Twitter syndication link in your own Blogger templates. Please try this out for yourself to see how it works and feel free to leave your comments below.
Reblog this post [with Zemanta]

2 comments:

  1. I together with my guys have been viewing the best strategies on your web site then instantly got an awful suspicion I had not expressed respect to the website owner for those techniques. Most of the guys are actually so passionate to learn all of them and now have honestly been having fun with those things. Thank you for being considerably considerate and for choosing variety of wonderful subject areas millions of individuals are really desperate to be aware of. My personal sincere regret for not expressing gratitude to earlier.

    ReplyDelete
  2. Excellent post. I want to thank you for this informative read. Keep up your great work.

    ReplyDelete