Adding a “Digg This” Button to Your Site

There are all kinds of ways to allow your users to submit your site to Digg. Digg itself even has a section with tools that allow you to do that. One of the ways is adding a “Digg This” button to your site.

Adding the Digg This button is pretty straight foward. All you have to do is add this piece of code into the page you want to get dugg.

<script src="" type="text/javascript"></script>

For blog users, this can be tricky. The reason is that you want the post to be dugg, but not usually the main url, so that people can go directly to the post itself. Every blog software displays the most recent posts on the front page. If you have this button on your blog post and it gets dugg, it will display how many diggs the post has. But when you look at the home page, it will show 0. This is because nobody has dugg the homepage, they dugg the blog post.

Digg itself provides a way to fix this problem. All you have to do is add an extra line of javascript with the URL of the dugg post in it, like this.

<script type="text/javascript">
digg_url = 'WEBSITE_URL';
<script src="" type="text/javascript"></script>

When you do this on your blog, the home page will show the correct number of diggs on your post, and it will display correctly on the actual blog post as well.

However, you may have a problem adding this code to your post in wordpress, as I did. I added the code to the post editor in wordpress, but it kept automatically escaping the single quotes in the javascript by inserting a backslash in front of them. This causes the javascript not to work once it is posted.

To correct this, I added double quotes instead of single quotes. This fixed the problem, and it now displays as it is supposed to.

On a side note, I would only add the “Digg This” button to your post after it has recieved more than a few diggs. It looks stupid if it only has one digg, and you were the one that dugg it.