Powered By

Powered by Blogger

Selasa, 26 Januari 2010

Partially Fixing Disqus Comments To Not Get Penalized By Google

This post is for those of you which have a blog and run Disqus comment system on it.

Firstly, let me tell you the exact story: I haven't noticed this before, but if you look at the source code of a post (post, not main page) of probably all blogs using Disqus (except Web Upd8 and Mashable), and search for some words in the post, you will see them displayed twice: once in the actual post and once in a div with the "disqus_post_message" id, which is not visible on the actual page because it's hidden. This basically means all your posts text exists twice on your blog which is of course not very good in terms of SEO. Even worse, the "disqus_post_message" has the style "display:none", which Google interprets as trying to hide content.

If you take a look at Mashable, this does not occur because they use a very advanced customization of Disqus, with the comments text being actually displayed in the source code of their pages, not only in an embeddable window like on the rest of the blogs (having the comments show up on the actual page and not in an embedded window is very good from the search engines point of view).

How I partially fixed it


I don't know how to make the comments show up on the actual post page, but what I've managed to do - and I'm actually still testing to see if there is something wrong with this - is to remove the disqus_post_message div and with it, the double text that it creates in the pages source code. Please note that I've done this for a blog on the Blogger platform, and I don't know if/how this applies to other blogging platforms.

What I did was to search for this in my blog template (before doing this, I strongly suggest you make a backup to your template):
<div id='disqus_post_message' style='display:none;'><data:post.body/></div>

and completely remove it. Below this line, there is some javascript which looks like this:
<script type='text/javascript'>
var disqus_url = '<data:post.url/>';
var disqus_title = document.getElementById('disqus_post_title').innerHTML;
var disqus_message = document.getElementById('disqus_post_message').innerHTML;
</script>

From which I've removed this part:
var disqus_message = document.getElementById('disqus_post_message').innerHTML;


After removing these, I've also seen improvements in the page load speed.

A final note: I've also deleted this div:
<div id='disqus_post_title' style='display:none;'><data:post.title/></div>

Which makes the post title be displayed once again for Disqus, but hidden ("display:none"). Some might need this for displayed some Disqus widgets on their blogs, but I don't so I also removed this. Hopefully, everything will run smoothly without it.

That's about it. Hopefully this will help some bloggers out there :)

Tidak ada komentar:

Posting Komentar