Adding a Twitter “Tweet this” button to blog posts
Adding a “Tweet this” button will enable your readers to share your articles with other Twitter users. This will help promote your blog and possibly increase your Twitter followers.
The button we are making will appear at the footer area of each post.
Update Nov. 2010
Twitter has come up with its official Tweet button. Visit Add Twitter tweet button to Blogger posts for a step by step installation instructions.
You can see the button in action in my widget showcase blog. Click the button and see what happens. I use exactly the same code in there as I do in this tutorial.
If you like what you’ve just seen, then proceed,
- Login to your to your Blogger account.
- Go to Dashboard > Design > Edit HTML.
- Back up your template.
- Tick the Expand Widget Templates check box on top right of the HTML window.
- Find the your post footer, look for following lines in your HTML codes:
<div class='post-footer-line post-footer-line-2'>
- This is your second line of post footer section. Usually a blog has 3 lines –line 1 to line 3. You decide which footer line your want to place the button at.
- Now copy the codes below:
<a expr:href='"http://twitter.com/home?status=Reading " + data:post.title + " " + data:post.url' title='Post this article on Twitter' target='_blank'><img src='yourTwitterButtonURL'/></a>
ReplaceyourTwitterButtonUrl
with the link to your button. If you want to, you can changeReading
andTweet this article on Twitter
phrases with your own phrases. Or you can remove them. - Insert (paste) the codes immediately below the line in step 5. The codes now will look like this:
<div class='post-footer-line post-footer-line-2'> <a expr:href='"http://twitter.com/home?status=Reading " + data:post.title + " " + data:post.url' title='Post this article on Twitter' target='_blank'><img src='yourTwitterButtonURL'/></a>
- Click PREVIEW and see if your Tweet this button appears at the footer of each post. If it does, then click SAVE TEMPLATE.
- Now you can test whether the button works or not. Click the button, if Twitter page pops up and the message is somewhat similar with my Tweet this, then it works.
- Enjoy!
Update: Looking for nice cute Tweet This buttons? Look no further, check this out: 50+ Free “Tweet This” buttons.
Known bug:
Readers reported an "Invalid Unicode value in one or more parameters" error pops up on Twitter when attempting to tweet posts with an apostrophe in the titles.
So far I haven’t find any solution for that. But I did find an alternative, in the form of Twitter’s official Tweet button and Tweetmeme’s Retweet button.
41 comments to "Adding a Twitter “Tweet this” button to blog posts"
what's yourtwitterimageurl? is it your twitter url?
@Josh,
It's the image you want to display in your post (so you readers can click on it). In my case the image is the TWEET THIS button on the left of ADD THIS button. I keep this image in Photobucket, and I use the URL (link) to that image in my code.
Thanks for stopping by.
To make more sense, I'm changing yourTwitterImageurl to yourTwitterButtonURL since the title use "Button" not "image".
Thanks Greenlava!
You're welcome.
Sorry to post again, but I'm unable to get this to work. Should I be replacing or deleting any of the quotation marks around "yourTwitterButtonURL"? Maybe it's not working because I'm using my flickr photostream page and there's an @ in the url?
This is my flickr url: http://www.flickr.com/photos/37587854@N07/3493109976/
@Josh,
I think this is your correct link: http://farm4.static.flickr.com/3373/3493109976_71d0aa024f_m.jpg
don't forget the quotation marks.
Thanks and enjoy.
Ok, this works if I want to put the button @ the bottom of every post, however, what if I wish to put it in the upper left....
Hi Batman,
You mean just below post title?
If that's the case, look for post-header. I see your blog has post-header-line-1 empty. Put the code in there.
Thanks for flappin' by :)
hi there,
I am trying to do this and can only find the footer1 line ,not footer2. also where do i get the url for my botton? I chose a free tweet this button and saved it in my documents.
Go to Layout>Edit HTML, and tick the Expand Widget Templates check box. Use Ctrl+F to find this code in the code window:
< div class='post-footer-line post-footer-line-3' >
< span class='post-location' >
< /span >
< /div >
(I put spaces after "<" and before ">" t prevent error in comments)
Insert Tweet This code immediately after < span class='post-location' > line.
Thanks
Thanks of rthis post! I was able to install it, but, when I tested it, it posts the full URL. How can I install bit.ly or tinyurl into the tweet this code to make it automatically shorten the URL of my post? Thanks much, Georgia
Hi Moms For Life,
In order to do that you have to incorporate bit.ly's Tweet & Track Chicklet into the code. I haven't reach there just yet :). For the time being I suggest you try this one by Blogger Buster.
well how do i add tecnorati button link between each post and what is the step even for stumbleupon button adding i m facing big problems, the problem is that even after adding the code its not working proper showing close {tag} properly when it is closed, wht to do reply soon
I have Added this Tool To My blog. It is great , thank for sharing it.
My blog is http://hollywoodmoviestodownload.blogspot.com
raj,
To add Technorati button go here
Deepak,
My pleasure
Finally, a code that works, thank you so much!
Angela,
Glad you like it.
thanks!!
You're welcome प्रवीण त्रिवेदी...प्राइमरी का मास्टर.
Hi, this is great. But a problem arises with me. When i click on tweet me button it takes me to twitter home where it shows whole url and not short one and after i update it, it shows short url. Is there any way by which in twitter box it shows short url??
here is my blog : businessaround.blogspot.com
CHANGE YOURSELF!!!,
Welcome to Blogger Sentral. Similar question was answered in comment no.13.
Fantastico!
easy peasy
muchas gracias
pelirojo,
De nada
It installed perfectly and works for most of my blog posts but I've noticed if any of my Blog post titles have an apostrophe in them then a "Invalid Unicode value in one or more parameters" pops up on twitter.
Jessie Gray,
Been trying, but I still can't find a solution. I'll update this post when I comes up with one.
perfect :D
I absolutely love your site! Whenever I want to do anything I come here, and you've got instructions for it! Thanks
Add me to the list of satisfied customers. I came here on a search for this very thing.
At first, I was thinking, "Should I hotlink? Nah. Where do I store my Twitter button?" Picasa Web. Duh!
Anyway, I'm going to be checking out your work in the future. Thanks!
@claza
@Remodelaholic
Thank you and do come back...
@Stormbringer
My pleasure.
"Are You a Real Cowboy?" <-- good one :)
dear Greenlava i cont able add twitter buttun in my blog. i followed as per u r guidelines but by templete not supporting. plz help me
@Pharmajobsindia
Whoa! that's a lot of blogs in your profile :) Can you tell me which one are you referring to?
Hi, im having the same problem as Jessie Gray, when strange characters are used i get the Invalid Unicode value in one or more parameters.
any solutions..?
@Mockus info
I'm afraid there is none so far :(
it seems that there is a problem with the encoder,
you can send your url encoded, you have an url encoder here: http://www.hypergurl.com/urlencode.html
use UTF-8 and you will be able to share it with strange characters
@Anonymous
Thank you for your suggestion, but I think in this case it's not possible. If the url was a static url, you can url-encode it but this tweet-this code uses a dynamic url. There are two variables -data:post.title and data:post.url. The trouble comes from data:post.title.
Thanks for the post. I waz looking for it..;)
http://shaikhwaqar.blogspot.com/
Hi, what's the process if i want to add below the post title as I paste the code for Sharing button below the post...plz take a look
http://justimaginnow.blogspot.com/
@James
Find this code: [data:post.body/]
Paste the tweet this code (in step 7) right below (after) it.
James,
Were you ever able to find a solution for this problem? I've currently run into it and need to find a way to fix it for my application to be functional. Please let me know if you've figured anything out! Thanks.
@mkp
Try Adding the official Twitter tweet button.
Comments on this post are closed.