Search code examples
bloggerfacebook-comments

Facebook comment plugin treating same page as different


I've added the Facebook comment plugin on a blogger blog and it's working fine except that it's treating the same url differently on desktop and mobile devices. In the code that I use, there's a expr:href='data:post.url' which helps to identify the current url of the page. The issue is, when a user is on the desktop browser, the link will be something like example.blogspot.com/post1.html but the same link on mobile device will look something like example.blogspot.com/post1.html?m=1 where m=1 is added to identify that the user is on a mobile browser. There comes the issue. Facebook comment plugin is treating the same page as different pages simply because there's a slight difference at the end of the page (m=1). Result is, mobile users can't see comments which are made from the desktop browser and vice versa. Comments will be visible if I manually add a m=1 in the desktop browser. Mobile version of the blog is turned off. How to fix this?

One related question though not same problem: Facebook comments plugin - same comments on every page


Solution

  • Use

    expr:href='data:post.canonicalUrl'
    

    instead of

    expr:href='data:post.url'
    

    The benefit of using data:post.canonicalUrl is that the URL always remains the same whether you are using it on desktop or mobile. Also, it always returns the blogspot.com version of the URL (when you are not using a custom domain) remaining unaffected by the changing ccTLDs