Saturday, February 16, 2008

How I Added a Digg Button to My Blogspot Posts

I've had a Digg button for a long time. I thought it had worked fine since I threw the script code into my template, but it had one major bug I didn't see (It's difficult to test these things without getting Digg pissed at you...): it didn't work from the front page. This was pointed out in a comment on my last story. About fifteen minutes of searching came up with a solution to the problem, but it's still not perfect. I thought I'd let you know about it.

First of all, you can copy the Digg code from the Digg site, and it will work when someone is reading a particular ppost with the permalink. If the user tries to Digg from the front page, however, it linked to the front page, not the post, and future Diggs on new posts made from the front page would Digg the first story, instead. Ugh!

So, the question becomes how to find the permalink variable. It's not as easy as you think, and that's because it's not named anything like permalink. The permalink is actually data:post.url, so you will need to change the Digg button accordingly.

Since I was changing stuff already, I signed up for and got a social button. Put it in the footer section of your template, and you're finished. It seems to work well. If anyone has trouble, please alert me!


Post a Comment

Other I' Been to Ubuntu Stories