FastComments.com

Add Live Commenting to Blogger Blogs

This guide adds the FastComments live commenting widget to the post pages of a Blogger blog by editing the blog's theme HTML.

The code is added once to the theme and applies to existing and future posts. Each post gets its own comment thread, identified by the Blogger post ID.

This guide requires a FastComments account. You can create an account here.

Step 1: Open the Theme HTML Editor Internal Link

Sign in to Blogger and choose the blog to update.

Before editing the theme, save a copy of it. In the left menu, click Theme. In the top right, click More, then Backup, then Download.

To open the theme HTML editor:

  1. In the left menu, click Theme.
  2. Under My theme, click More, then Edit HTML.

Step 2: Add the FastComments Code to the Post Template Internal Link

In the theme code, find the <data:post.body/> tag. Blogger replaces this tag with the content of each post. Paste the following code directly after it:

Blogger FastComments Code
Copy Copy
1
2<b:if cond='data:blog.pageType == "item"'>
3 <div id='fastcomments-widget' expr:data-url-id='data:post.id' expr:data-url='data:post.url' expr:data-title='data:post.title'></div>
4 <script src='https://cdn.fastcomments.com/js/embed-v2.min.js'></script>
5 <script>
6 //<![CDATA[
7 (function () {
8 var container = document.getElementById('fastcomments-widget');
9 window.FastCommentsUI(container, {
10 tenantId: 'demo',
11 urlId: container.getAttribute('data-url-id'),
12 url: container.getAttribute('data-url'),
13 pageTitle: container.getAttribute('data-title')
14 });
15 })();
16 //]]>
17 </script>
18</b:if>
19

When you are logged in to FastComments, the snippet contains your tenant ID in place of demo. If it still shows tenantId: 'demo', log in and reload this page, or replace demo with your tenant ID.

Click Save to save the theme.

The code works as follows:

  • <b:if cond='data:blog.pageType == "item"'> limits the widget to single post pages. Blogger reports a page type of item for post pages, index for the home page, and archive for archive pages, so the widget is not rendered on pages that list several posts.
  • The expr: attributes write the post ID, permalink, and title into the container element. data:post.id is the numeric post ID and is used as the urlId, so the comment thread stays attached to the post if its permalink changes. data:post.url is stored as the link to the post in notifications and moderation tools.
  • Blogger themes are XML documents. The //<![CDATA[ and //]]> lines mark the script as character data so the theme parser does not try to read it as markup.

If the theme contains <data:post.body/> more than once, add the code after only one of them. The widget renders into the first element with the id fastcomments-widget on the page.

Open any published post to confirm that the comment widget appears below the post content.

Step 3: Hide Blogger Comments Internal Link

Blogger shows its own comment form under each post. To show only the FastComments widget, hide Blogger comments for the whole blog:

  1. In Blogger, click Settings in the left menu.
  2. Under Comments, set Comment location to Hide.

Hiding Blogger comments does not delete existing comments. Selecting another Comment location option shows them again.