Saturday, May 24, 2008

Integrating ShareThis into Blogger

Look at the end of each post. I integrated "ShareThis" button into my blog this morning. "ShareThis" is a bookmark widget for bloggers. It can make your visitors share your contents more easily. Now let me tell you how to integrate it into your blog hosted by Blogger.com.

Click here to get the code. It advises you to create an account. But it is not necessary. If you want to obtain the code only, just click "No Thanks" button. Then you can custom the button's appearance. I think the default is not bad for me. So I skipped this step and click the "Get ShareThis Code" button. You'd better copy the code to your favourite editor so that you can use it after a while.

Go to your Blogger administration panel and open "Layout" tab. Then click "Edit HTML" and check "Expand Widget Templates". See below:
sharethis_blogger_1

Add the code in <head>...</head>. It's better to use HTML comment to mark the code.
sharethis_blogger_2

Search for "<data:post.body>" in the template. Add the code below following it:
<p>
<script language='javascript' type='text/javascript'>
SHARETHIS.addEntry({
title: '<data:post.title/>',
url: '<data:post.url/>'
}, {button:true} );
</script>
</p>
sharethis_blogger_3

That's OK. The function "SHARETHIS.addEntry" will create an instance, i.e. the ShareThis button. "title" and "url" are two useful arguments. They specify the post URL and the title. If they are omitted, the current URL and the HTML title are used instead. <data:post.title/> and <data:post.url/> are the Blogger template tags. They stand for the post's title and its permanent URL. If you want to know more about "ShareThis" API, please see the manual.

7 comments:

josh909 said...

just the info i was after - well explained post - great work.

Anonymous said...
This comment has been removed by the author.
Anonymous said...

Thanks you very much for this. Well explained. ShareThis is now installed on my blog. Thanks AGAIN!

Shaheen said...

Thank you! This is very helpful :D

Anita said...

Thanks for posting this :)

Anonymous said...

No Prescription medication Pharmacy. Order Generic Medication In own Pharmacy. Buy Pills Central.
[url=http://buypillscentral.com/buy-generic-brand-levitra-online.html]Order Discount Viagra, Cialis, Levitra, Tamiflu[/url]. prescription generic pills. Top quality pills pharmacy

Anonymous said...

just what I was looking for! thanks!!