TechBuzzPro

How to Add Facebook Comments to Your Website

· 5 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To add Facebook comments to your website, you need a Facebook Page (or a developer app) and a small block of code called the Comments Plugin. The plugin lets visitors comment using their Facebook login, and comments appear both on your site and in your Facebook Page's inbox. The setup takes about ten minutes and requires no coding beyond copying and pasting a snippet.

What You'll Need

  • A Facebook account and a Facebook Page (recommended for moderation and branding).
  • Admin access to your website's HTML, or a CMS that allows inserting custom code (WordPress, Shopify, Wix, Squarespace, etc.).
  • Your website's URL (the exact page or domain where the comments will appear).
  • Basic ability to edit HTML or use a plugin/embed block.

Step-by-Step

  1. Create a Facebook app (optional but recommended). Go to developers.facebook.com and create an app of type "Business" or "None." This gives you an App ID, which helps with moderation and analytics. If you only need basic comments, you can skip this and use the plugin without an App ID, but some features may be limited.
  2. Get the Comments Plugin code. Visit the Facebook Comments Plugin page (developers.facebook.com/docs/plugins/comments). Enter the URL of the page where the comments will appear. Set the width (usually 100% or a fixed pixel width) and the number of posts to show. Click "Get Code." You'll see two code snippets: one for the JavaScript SDK and one for the plugin itself.
  3. Add the JavaScript SDK to your site. Copy the first snippet (the SDK) and paste it just after the opening <body> tag on every page where you want comments. If you already have the Facebook SDK loaded for other plugins (like the Like button), you can skip this step.
  4. Place the plugin code where comments should appear. Copy the second snippet (the <div class="fb-comments"> block) and paste it into your page's HTML at the exact spot where you want the comment box. On WordPress, you can use a Custom HTML block or a plugin like "Facebook Comments" to insert it without editing theme files. On Shopify, add it to the product template or use an app. On Wix/Squarespace, use an embed HTML element.
  5. Set the correct URL. In the plugin code, the data-href attribute must match the exact URL of the page. If you leave it blank, Facebook uses the current page URL, which can cause comments to split across www/non-www or http/https versions. Always specify the canonical URL.
  6. Moderate comments. Comments are tied to the URL. To moderate, go to the Facebook Comments Moderation Tool (developers.facebook.com/tools/comments) and select your app. You can also add yourself as a moderator by adding <meta property="fb:admins" content="YOUR_FACEBOOK_USER_ID" /> in your page's section. For Pages, comments also appear in the Page's inbox under "Comments."
  7. Test it. Open the page in a browser, log in with a test Facebook account, and post a comment. Check that it appears and that you can moderate it. Also test on mobile.

Common Mistakes

  • Using different URLs for the same page. If your site is accessible via both http and https, or with and without www, comments will be split. Always use the canonical URL in data-href and redirect the other versions.
  • Forgetting the SDK. The plugin won't load without the JavaScript SDK. Make sure it's included once per page, ideally right after <body>.
  • Placing the code in the wrong spot. The plugin div must be inside the <body>, not in the <head>. Also avoid placing it inside a hidden container; it may not render.
  • Not setting a width. The plugin needs a width; if the container is too narrow, comments may be cut off. Use data-width="100%" for responsive layouts.
  • Ignoring moderation. Without moderation, spam and off-topic comments can appear. Set up the moderation tool and assign moderators.

Tips

  • Use the same App ID across your site to centralize moderation.
  • Enable "reverse order" if you want newest comments first.
  • Add the data-numposts attribute to control how many comments load initially.
  • For WordPress, consider a dedicated plugin to avoid editing theme files and to handle updates.
  • Keep the plugin code in a template or include file so you don't have to paste it on every page manually.

Troubleshooting

  • Comments don't appear: Check that the SDK is loaded and the plugin div has the correct data-href. Use the Facebook Sharing Debugger (developers.facebook.com/tools/debug) to scrape the URL and refresh the cache.
  • Comments show on some pages but not others: Ensure the SDK is on every page and that the data-href is unique per page. If using a CMS, check that the code is in the correct template.
  • Moderation tool shows no comments: Make sure you're using the correct App ID and that the URL matches exactly. Comments are tied to the URL, so a slight difference (trailing slash, query string) creates a new thread.
  • Plugin is cut off on mobile: Set data-width="100%" and ensure the parent container has a defined width. Avoid fixed pixel widths that exceed screen size.
  • You see an error about "App not set up": If you created an app, ensure it's in Live mode and has the Website platform added with your site's URL.

Frequently Asked Questions

Do visitors need a Facebook account to comment?

Yes, the Facebook Comments Plugin requires users to log in with their Facebook account to post a comment. They can also comment using their Facebook Page if they manage one.

Can I moderate comments before they appear?

Yes, you can enable moderation in the Comments Moderation Tool. You can set it to require approval for all comments or only for comments with certain keywords.

Are comments indexed by Google?

Facebook comments are loaded via JavaScript and are generally not indexed by search engines. If SEO is a priority, consider a native comment system instead.

What happens if I change my website's URL structure?

Comments are tied to the exact URL. If you change URLs, old comments won't appear on the new URLs. You can use the Facebook Comments Migration tool to move comments, but it requires technical setup.

Is the Comments Plugin free?

Yes, the plugin is free to use. There are no charges for adding it to your site.

Can I use the plugin on multiple websites?

Yes, you can use the same App ID across multiple sites, but each site's comments are separate based on the URL. For separate moderation, create separate apps.