News spreading about Google indexing Facebook comments inspired my to add them to this blog.

Many tutorials are around, but none seem to work in my case; I don't use Wordpress and the code generated by the Facebook developer page seems not to work either.

So, here it is how I did it. First I created a new Facebook app (many tutorials around, in case it's not obvious how to do that), and an took note of the "App ID". Then I've added this to the beginning of the page

<div id="fb-root"></div>
<script>(function(d){
   var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
   js = d.createElement('script'); js.id = id; js.async = true;
   js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1&appId=APP_ID";
   d.getElementsByTagName('head')[0].appendChild(js);
}(document));</script>

(that I actually got from Facebook JavaScript SDK documentation) replacing APP_ID with the ID I got creating the app. Finally, I added

<div
    class="fb-comments"
    data-href="POST_URL"
    data-num-posts="2"
    data-width="500">
</div>

where I wanted the comments to apper, replacing POST_URL with the absolute URL of the post.

Comments