How to disable Facebook Comments from showing up on Blog Home Page and Category Pages?

I’m currently working with Facebook Comments on a Squarespace.com website. Squarespace gives us the ability to add HTML code blocks, so implementing the code for FB Comments is easy.

The problem is Squarespace displays this code on the Blog Home Page and Category/Tag Pages, as well as the Full Blog Post. I only want the Comments to appear on the Full Blog Post.

I can use the following code to tell Squarespace to look for the Post’s PERMALINK and display only when on that page, but the Script no longer works with Facebook’s Comments (it used to).

Works:

<script type="text/javascript">

<!--
var docURL = document.URL;
if (docURL == "%PERMALINK%")
{
document.write('<p>This is test text.</p>');
}
-->
</script>

Does Not Work:

<script type="text/javascript">

<!--
var docURL = document.URL;
if (docURL == "%PERMALINK%")
{
document.write('<div id="fb-root"></div>
<sc'+'ript>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#appId=153773241379548&xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</sc'+'ript>

<div class="fb-like" data-href="%PERMALINK%" data-send="false" data-layout="button_count" data-width="200" data-show-faces="false"></div>');
}
-->
</script>

Using the Facebook code, nothing shows up at all. Thanks for your help!

Answer

This question was only relevant to the Squarespace Version 5 system. Since Squarespace Version 6/7, Facebook Comments can now be implemented seamlessly by using the Squarespace Developer Platform.

To display Facebook Comments on a blog post page itself, but not the blog index, you’ll want to place the Facebook markup into your blog.item template file and do not place it anywhere else.

Leave a Reply

Your email address will not be published. Required fields are marked *