FastComments.com

Add Comments to Teachable Lessons

FastComments can be added to Teachable course lessons with the Custom Code block in the Teachable lesson editor.

This tutorial requires a FastComments account. Sign in before following the steps so that the code snippet on this page contains your account's tenant ID. You can create an account here.

Teachable supports custom code in lessons on the Builder plan and higher. Schools on legacy plans need the Basic plan or higher.

The Custom Code block is added to each lesson individually.

Step 1: Turn Off Teachable Lesson Comments Internal Link

Teachable lessons have a built-in student comments setting. To show only FastComments on a lesson, turn off Teachable comments for that lesson:

  1. Go to the Courses menu and select the course.
  2. Open the Curriculum menu of the course.
  3. Click the lesson.
  4. Under Lesson settings, turn off the Student comments toggle.

Teachable sets comments per lesson, so repeat these steps for each lesson that will use FastComments. The Student comments toggle appears only after the lesson has content.

Step 2: Add a Custom Code Block Internal Link

Open the lesson in the Teachable lesson editor and add a Custom Code block:

  1. Log in to your Teachable admin and select the course.
  2. Click the Curriculum tab, then select the lesson.
  3. In the Lesson Editor, click Add Content.
  4. Click the Custom Code block. A popup opens for the code.

Use the Custom Code block, not the Code Example block. The Code Example block displays code as text and does not run it.

Step 3: Paste the FastComments Code Internal Link

Copy the following code into the Custom Code popup:

FastComments Teachable Lesson Snippet
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script>
3<div id="fastcomments-widget"></div>
4<script>
5 (function fcLoad() {
6 // Use a different value in each lesson.
7 var LESSON_ID = 'my-course-lesson-1';
8
9 function tryLoad() {
10 var container = document.getElementById('fastcomments-widget');
11 if (!container || !window.FastCommentsUI) {
12 return setTimeout(tryLoad, 500);
13 }
14 if (container.fastCommentsSetup) {
15 return;
16 }
17 var pageUrl = window.location.href;
18 var pageTitle = document.title;
19 try {
20 pageUrl = window.top.location.href;
21 pageTitle = window.top.document.title;
22 } catch (e) {
23 // A cross-origin frame cannot read the parent page; keep the frame's values.
24 }
25 window.FastCommentsUI(container, {
26 tenantId: 'demo',
27 urlId: LESSON_ID,
28 url: pageUrl,
29 pageTitle: pageTitle
30 });
31 container.fastCommentsSetup = true;
32 }
33
34 tryLoad();
35 })();
36</script>
37

If the snippet contains tenantId: 'demo', you are not signed in to FastComments. Sign in and copy the snippet again, or replace demo with your tenant ID.

Setting the Lesson ID

Change my-course-lesson-1 to a value that is unique to the lesson, such as the course name followed by the lesson number. Each lesson that uses the same value shows the same comment thread.

The snippet sets urlId explicitly instead of deriving it from the page address. This keeps each lesson's comment thread separate whether Teachable renders the Custom Code block directly in the lesson page or inside a frame. The url and pageTitle values, used to link comments in notification emails and moderation tools back to the lesson, are read from the lesson page when the browser allows it.

Once the code is pasted, click Save.

Step 4: Preview and Publish Internal Link

Click Preview in the lesson editor to view the lesson with the comment widget, then click Publish to make the lesson available to students.

If the lesson is already published, changes to the Custom Code block are visible to students as soon as the block is saved.

Repeat Steps 1 to 3 for each lesson that should have comments, using a different lesson ID in each snippet.

Customization Internal Link

The widget's styling and behavior can be changed from the FastComments widget customization page without editing the snippet, or by adding configuration options to the snippet.

See the Customization Documentation for the available options.