Luckily for us, Bit.ly have created a JavaScript-based solution which shortens the URL to just a few characters and enables bloggers to add a Tweet This link configured for their posts. 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:
<b:if cond='data:blog.pageType == "item"'><span style='float: left; background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTrKhXkul9jZGgfOz9Dp7RniaP16wPMzI49uUMKqb4m5cgKtVsROYDBfJd1MCrdlRwhOjDhoDaOCmO3TJk6l2DcNagZ6RWoNNAyEriq9H4xESD7StcsjVslBxn1YyAw6NrLgjrsa98Oq3m/s128/twitter-16x16.png) left no-repeat; padding-left: 20px;'><script charset='utf-8' src='http://bit.ly/javascript-api.js?version=latest&login=tweettrackjs&apiKey=R_7e9987b2fd13d7e4e881f9cbb168f523' type='text/javascript'/>
<script charset='utf-8' src='http://s.bit.ly/TweetAndTrack.js?v=1.01' type='text/javascript'/>
<a expr:onclick='"return TweetAndTrack.open(this, \"" + data:post.url + "\");"' href='#'>
<span style='display:none;'>I'm reading: <data:post.title/></span>Tweet this!</a></span></b:if>
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:
Tweet this!
This link automatically generates a Bit.ly shortened URL for your post. When a reader clicks on this link, they are taken to Twitter.com (where they can log in if required) with a pre-filled Tweet which appears like this:
http://bit.ly/url I'm reading: [title-of-blog-post]
If you would prefer the prefilled Tweet to say something other than "I'm reading", you can edit this phrase in the code you add to your Blogger template. Readers can edit this pre-filled Tweet before updating if required.
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.
107 comments:
Thanks Amanda,
I was looking for this. This one is the best solution. Thanks
This is rendering an error over not being well formed. It doesn't like the login entity in the first script tag.
@br3ntbr0: My apologies, there was a slight error in the code with the ampersands. I've edited this now and checked again by pasting this same code into another of my templates, so all should work just fine now. You may need to refresh the page (f5) to see the changes though!
Hope this helps!
Thanks for the code. Two questions though.
1) Is there any way to have the URL appear at the end of the tweet instead of the beginning?
2) The link kept wanting to pop up a window. Since I use the popup blocker in Firefox, I got a warning but the page forwarded anyway. Do you know of a way to prevent this?
Actually, a simpler way to solve this problem is to merely add a third-party code that will connect to any social site you desire. The best I've found are:
http://www.addtoany.com/
http://www.addthis.com/
http://sharethis.com/
is there any ways for getting the url short without any js?
Hi Radith Prawira,
Yes, I have a solution for you. pls visit http://epayvn.info/2009/03/how-to-add-twitthis-to-your-blogger.html for the details.
I hope that this comment would not be deleted by the bloggerbuster administrator so that you can see the url of my post.
how abaut js?
@N.P
Hi. Tq. I've left message there. :)
But unfortunately it didn't work for me T_T
--
@Marzuki
JS = Javascript [?]
Hi Amanda,
This loks great but I guess you would like to suggest @tweetmeme its a lot cooler digg like twitter link.. it shows how many times the post got retweeted.. I'm using it in my blog now :)
Hmm,
What if you cannot find any of these things in your html code? What code would you add, to add this section of tweet code?
Thanks!
Danke funktioniert hervorragend !
Its a good tool for bloggers.. hehe.
Ya even if we couldnot use it on our blogger template, we could do it through other social bookmarking tools. And ya even those tools are easy to use. You need not go through all these.
I would prefer any other social bookmarking tools such as add to any or something else.
But even this is great.
I think that this is much better option, almost same, but less code and don't use any popup...
http://i-stuff.blogspot.com/2009/02/add-tweetthis-button-your-blog.html
This is fantastic Amanda! I am stoked to find this as I hated Twit This as it required people to log in each time and every other option either didn't allow for text - I changed your code to make the text include reference to my blog - or had monster urls.
The only thing I would ask is the same thing as Drew Kime above: Is there any way to have the URL appear at the end of the tweet instead of the beginning? (my code knowledge is very limited and I couldn't work that one out)
Cheth @tweetmeme looks cool, love the fact it counts the retweets, but the instructions as to how to install it are vague "Copy and paste the following code where you want the widget to be displayed."
It assumes knowledge of code that I don't have.
And when I have tried it it tweets my home page not the page specific to the blog entry being retweeted. Amanda's is much better and I can set up a search via tweetdeck to track any retweet's based off the extra text I added to her code that named my blog.
i have trouble with this :
error XML: The reference to entity "login" must end with the ';' delimiter."
please help me :)
I did it but the twitter icon and link is not showing in my blog. what to do?
i need help.
It works with FF but not with Chrome.
Thanks Amanda, great code to add to help get your posts exposure on Twitter
thanks Amanda...
i already use twitter... (http://twitter.com/citraglobal)
thanks for share..
Wow! Thanks for this. I found it here.
Thanks Amanda for the sharing, I was inserting manually tweet this post before this, which is why I'm so glad I found your post.
However, I do find that IE was unable to display this after I added in after footer @ body-post; even refreshed couple of times as suggested. Based on the commenters above, could it be only IE's viewing problem?
Thanks in advance.
@wchingya
-Social network/blogging
very good!
I added the code to my blog
http://thrillfiction2009.blogspot.com/
And saw no change whatsoever. I went through firefox and viewed through that and ie8. Same difference. I am green to all of this but help! Please.
Thank you to krisu. The code above wouldn't work for me for some reason; however, the code that krisu linked to worked for my blog. I appreciate that the blog owner did not delete the post and I thank everybody for their help. You can check it out here: www.kandiandkeith.com/blog/index.html. Thanks!
wow..i will use this....
amanda check u blog whit IE7 (error)...page cut off
@MandM
Amanda's code is cool I used the same thing few months back.. but turst me @tweetmeme is easy, I would be able to help you to install it.. yea you can track this via @tweetdeck as well..
Hi Amanda,
This was quiet simple to drag & drop in the HTML code section and useful trick for both sides :
1 case- You want to choose a post and tweet it up in your twitter profile.
2 case- or someone would tweet it up on his own twitter profile.
It's still great if you would select only specific posts and tweet them. I actually update my twitter automaticly from my blog so any new article i post it's showing up on my twitter.
So, anyway!! thanks for posting this.
This one rocks, Amanda! I'm definitely liking the 'tweet this' option! :)
I have added the code where you said it should be added , yet I do not see any button at all could you please help ...
Thank you to krisu
Hi, i used ur template cool_blue, everything is fine but when any one try to put comment then it doesnt show me box like before it also not show any reaction button please help me to short out the problem ...
www.solutionatoz.blogspot.com (blog)
gogosandeep85@yahoo.com email id
plese send me reply or inform me how to resolve it
Hey Amanda, please, please respond. When i try to put an html code on my website, it just shows up as what im giving the html for. So since you are using blogger, how do you put the html out without it changing to a link or widget? Once again please, please respond, I know alot of people who want to know this. Thank you.
Wew.. I'm going to use it but, first of all I have to register...
excellent write up! I added this to my site today. I had to make one minor addition by adding br / enclosed by angle braces to get it to be unsquished against my timestamp. Thanks for the code snippet!
I had some problems getting it where I wanted (it wants to butt up against "Posted by yarnpiggy" rather than on a line above it), so I did some totally crappy hacking of the hack; it's still not perfect, but it gets the job done. Thanks!
ok
Nice blog. Only the willingness to debate and respect each other’s views keeps the spirit of democracy and freedom alive. Keep up the good work. Hey, by the way, do you mind taking a look at this new website www.indianewsupdates.com . It has various interesting sections. You can also participate in the OPINION POLL in this website.
Kindly note: The comments section is having problems so you may not be able to comment right now but it will available in a few days. We are also planning to get Live Cricket in our website within this week.
Dear friend, if you have any suggestions or information or news which you think has been ignored by the mainstream media, kindly let us know. We will try to implement that in our website.
Kindly go through the entire website. Who knows, it might just have the right kind of stuff that you are looking for. If you like this website, can you please recommend it to at least 5 of your friends. Your little help would help us in a big way.
Thank you,
The Future Mantra
i will add twitter on my blog. Hopefully, my traffic would increase significantly.
How do I reverse it?
Here's the order I have:
http://bit.ly/nlVPg I'm reading: Asians in art
Here's the order I want:
I'm reading: Asians in art | http://bit.ly/nlVPg
Worked a treat. Thank you so much for this.
The button really is cool. too bad I could not locate the post-footer code in my template.
why no recent updates !!
Hi,
Is there anyway to have this so it shows up on each post on my home page (so readers don't have to visit individual posts to Tweet it)?
hi I'm limferdi one of the avid readers of your blog, I get to learn many things here and I even applied some of your tips on my blog. Pls add me to your blog roll and I'll add you up to my new blog it's http://limferdi-nest.blogspot.com thank you
nice work done amanda!
this is really working
Excellent! Thanks..
Nice site, by the way!
Melvin Durable
melvindurable@gmail.com
YHX 4 YOUR INFO
Yes...i like your theme. Very nice share. thanks anyway.
Nice article .. http://moneyforinvestment.blogspot.com
Nice article.. thanks
thnk u amanda....
and i vote your blog to in Bloggers choice award 09
thanks Amanda, but it seems not working in my blog..
thx amanda, i like your blog.. and your posting too
when i open this blog, i found something 4 my blog.....thanx amanda...ur the best
Hi Amanda :)
Thank you. This is wonderful. I tried adding it to my main blog, but I couldn't get it to work. It shows, but when you click, it just redirects to the blog again. Perhaps because I still use the classic blogger template? (emailed you too)
These links only show up when you're viewing a specific post. When you're on the main page of my blog, for example, you don't see the Tweet This link. Click into any specific post, however, and it's there. Is there a way to get it to appear on the main page as well?
Amanda, you always have something good and useful for us! I will always recommend your blog for tips and tools and reliable information!
Thanks,
Worked great!
http://optionsincomereport.blogspot.com/
Yeah its really nice.
Infomist Services
Hmmmm, I added the code to www.loveofbabyonline.com but no changes. :(
Hi - thanks - works a treat. I added it to:
http://www.home-improvement-blog.co.uk and
http://purple13.blogspot.com (personalised photo gifts) blog.
The 'Tweet this' and icon appear in the footer when you click on an individual post to read it, rather than under each post when you're looking at the overall blogs 'home page', if that helps anybody above whose added the code but can't see the link appearing.
Thanks for your help with this.
Good luck everyone else and hopefully see you over on Twitter? - http://twitter.com/fabphotogifts
Hi - Just wanted to add a little clarification to my earlier remark about anybody using this but thinking it isn't working.
The Tweet this (& logo) only appears when you click on an individual story / article as it takes this information to create a link to that article.
The alternative is to put a 'Tweet this' link on your sidebar of your main blog and allow people to tweet the blog url rather than the post url.
Depends how focused you want to make the sharing.
Jonathan
Hi Amanda
Thanks for that - the code worked a treat (or should I say 'tweet').
I've added it to two blogs - one is for Fabulous Photo Gifts - http://purple13.blogspot.com, the other is on a home improvement quotes blog - http://www.home-improvement-blog.co.uk.
To give the words 'tweet this' a little space, after the logo, I added a
before the words Tweet this.
One question - I tried changing the image for another (replacing the image src link) but assume your javascript has something in it that leaves a 16x16 pixel space as the spacing went all wrong?
Be nice to hear back from you on that one.
To anyone else above struggling - just re-check you're entering the block in the right place, watch out you're not copying and pasting and missing an open or end bracket.
Also, as i see it, this script has to only appear when you open the actual article in its own window as it looks like it takes its title for the shortened url from that page title.
Regards
Jonathan
Twitter - http://twitter.com/fabphotogifts
Thanks a Ton Buddy !!
I just implemented this on my blog(www.msigeek.com)and it works like a charm.
Hi Amanda,
I did it in 5 minutes and it worked and I'm using the JS-Kits commenting system.
It took me only 5 minutes to add it to my js-kit commenting system blogger...Easy!
Thanks
Hi---great code thanks! The only issue is- you cant see it on the main page, only when you go into the post. Any updates for this prob yet? Thanks!
this is not working on my blog
Just wanted to say thank you, so thank yoy
Very helpful tools for blogger, thanks.
Thank You Amanda..nice :-)
this is great - just added it here thanks!
Thanks amanda!
Regards from costa rica.
This is great! Is there a way to get it to show up at the bottom of a post from the main blog page? Right now a reader has to click on the post itself to see the "tweet this" option.
Thanks!
Thanks for all your help! This is a great site, your tutorials have been of much assistance to me setting up my blog.
Glad you posted this.
You might think about not having ads play sounds automatically on your blog.
Thanks so much! Just added it to the Favors With Love blog! Awesome!
thank amanda...
i will take it,,
great article
th u v much
Nice think THX
Is there any change to show number of tweets per post?
Like similar WP-plugin is doing.
Thanks for sharing this. I was looking to have this link with URL shortening feature and you have provided one.
Thanks!
Thank you. Works great (after I removed the IF tag).
It's an amazing trick.Thanks a lot!
It's not working for me, which I'm guessing means I'm being dumb about something. I inserted the code after the ".post footer {" section, between its closing curly brace and the next section - ".post-footer .post-timestamp," . I don't get anything indicating tweet-ability on the displayed page. I also tried inserting the lines on the next physical line after that opening curly brace (ie,the code was insserted as the very first thing within the curly braces) ; also nothing. Can you suggest what I might be doing wrong?
Thank you.
It looks like this works only when viewing a specific page post by permalink. Is there something I can use to have the "Tweet This" show up when you're just scrolling through the whole site?
This did not work for me at all and I tried several times inserting it....what am I doing wrong because I REALLY, REALLY want to add the "Twit This" option to my blog posts. I hope to hear from you (or someone) please!
This doesn't seem to be working on my blog (http://scrubsandpubs.blogspot.com). Help? I'm trying to do this with the code for the ShareThis button too.
Thank you! removed the IF tag and this works like a charm.
Thanks very much! Very helpful
www.lostinparis.co.uk
I just added this to the site and it was easy. The one of few times something worked the first time. Thanks for the help!
Thanks for the tip.
I managed to embed the badge to my posts, hopefully people will start tweeting my articles!
MobileSpoon
nice trick
Cool! Thanks for the tips. I've already added it on my blog.
http://justmypersonalopinions.blogspot.com
I've just added this to my site: wearable-intelligence.blogspot.com BUT, I removed the first IF statement. ie, it now reads
(b)(span ...)
everything as it was
(/span)(/b)
where I'm using parenthesis instead of angles so the post doesn't turn into HTML.
This seems to work -- so I get a tweet this on the front main page for every post, and don't have to click on teh post first (as noted by the posts above..
and the tweet activates in the same browser window (although it tries to open a new window). My firefox has pop-ups off, so I don't actually see the pop-result.
Amanda: any thoughts how to stop the pop?
hello, I added it and it works -no big deal. It's shown at the end of a post. Thank you!
great.
Thank amanda
My eyes hurt from looking up ways to do this...THANKS!!!
does any other url shortening service provide this feature
what if you wanna add more social bookmarks (with own picture) under each post ? I'm looking around for this script but no luck so far. I have some cool bookmark icons I wanna use under each post with correct link without having to copy paste everytime the exact link when I post a new message.
hope you guys can help.
greetings
Simple and brilliant.
I will add it to Yourblogsite.com soon
What about for those of us who still use classic blogger templates?
This code didn't work on our blog, but http://sharethis.com/ certainly did!
You can check how share this looks like on our site: http://nighttimebrothers.blogspot.com/
You're so goooood! Thanks for the how-to!
Post a Comment