How to Add Comments to a Static HTML Blog

A practical step-by-step guide to adding serverless comments to static HTML and Jamstack blogs using Giscus, Utterances, and GitHub Discussions.

How to Add Comments to a Static HTML Blog
Static HTML Starter Series · Part 7 of 7

One of the defining benefits of running a static blog is the total absence of database bloat. But when developers decide to add reader comments, they frequently hit a dilemma:

"If my blog is just static HTML files, where do comments get stored? Do I have to install WordPress or set up a MySQL database just to let people talk?"

Fortunately, you do not. Modern static websites use serverless comment systems that delegate discussion threads to secure, high-availability backends—most notably GitHub Discussions.

In this seventh and final part of the Static HTML Starter Series (after adding site search in Part 6), you will learn why traditional comment plugins like Disqus are obsolete, explore the best open-source alternatives, and follow a step-by-step tutorial to install Giscus on any static HTML blog.


Why Traditional Comment Plugins Fail

For years, Disqus was the default solution for static websites. However, over time, traditional hosted comment plugins have become notorious for:

  • Heavyweight Bloat: Downloading up to 2MB of third-party JavaScript on every single page load.
  • Intrusive Tracking: Injecting dozens of advertising trackers and cookies that trigger GDPR compliance headaches.
  • Aggressive Ads: Inserting sponsored content and native advertisements directly into your layout.

By contrast, modern open-source comment engines like Giscus and Utterances are 100% ad-free, cookieless, lightweight, and completely open source.


The Top Static Comment Systems Compared

SolutionBackend StorageAuthenticationTracking & AdsBest Use Case
GiscusGitHub Discussions APIGitHub OAuthZero Ads, Zero TrackingDeveloper blogs, tech publications, tutorials
UtterancesGitHub Issues APIGitHub OAuthZero Ads, Zero TrackingMinimalist developer portfolios
FlarumSelf-hosted PHP/MySQLMulti-provider OAuthSelf-managedFull standalone community forums
DisqusProprietary CloudSocial / EmailAd-supported / TrackingGeneral consumer lifestyle blogs

Step-by-Step Tutorial: Adding Giscus to Your Static Blog

Giscus is our top recommendation for static websites. It leverages the official GitHub Discussions API:

  • Every blog post automatically maps to its own discussion thread.
  • Readers can reply, format in Markdown, and add emoji reactions (±, ♥, &rocket;).
  • When a reader comments, you receive a native GitHub notification.

Step 1: Prepare Your Public GitHub Repository

  1. Ensure your website repository (or a dedicated comments repository) is Public.
  2. Go to your repository settings on GitHub: Settings → Features.
  3. Check the box for Discussions to enable GitHub Discussions.

Step 2: Install the Giscus GitHub App

  1. Visit the Giscus GitHub App page.
  2. Click Install and grant access to your public discussions repository.

Step 3: Configure Your Giscus Snippet

Visit giscus.app and enter your repository details:

  • Repository: YourUsername/your-repo-name
  • Page ↔ Discussion Mapping: Choose pathname (this automatically associates /blog/my-post/ with a discussion entitled /blog/my-post/).
  • Discussion Category: Select General or Announcements.
  • Theme: Choose light, dark, or preferred_color_scheme.

Giscus will generate a clean <script> embed:

<section class="comments-container">
  <h3>Discussion &amp; Feedback</h3>
  <div class="giscus"></div>
</section>

<script src="https://giscus.app/client.js"
        data-repo="YourUsername/your-repo-name"
        data-repo-id="R_kgDOXXXXXX"
        data-category="General"
        data-category-id="DIC_kwDOXXXXXX"
        data-mapping="pathname"
        data-strict="0"
        data-reactions-enabled="1"
        data-emit-metadata="0"
        data-input-position="bottom"
        data-theme="light"
        data-lang="en"
        crossorigin="anonymous"
        async>
</script>

Step 4: Drop the Code into Your HTML Template

Paste the snippet directly into your blog article layout (for example, right below the article content, just as we do on StaticStack).

Because Giscus uses the async attribute, it loads completely asynchronously without blocking the initial rendering of your blog text!


Styling & Theme Integration Tips

To ensure the comment area matches your website's typography and spacing, wrap the widget in a styled container:

.comments-container {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.comments-container h3 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-main, #0f172a);
}

If your website supports dark mode, you can dynamically update the Giscus theme by sending a postMessage to the Giscus iframe whenever your user toggles themes:

function setGiscusTheme(theme) {
  const iframe = document.querySelector('iframe.giscus-frame');
  if (!iframe) return;
  iframe.contentWindow.postMessage(
    { giscus: { setConfig: { theme: theme } } },
    'https://giscus.app'
  );
}

Frequently Asked Questions

Do readers need a GitHub account to comment with Giscus?

Yes. Readers sign in with their GitHub account. For developer, design, and technical blogs, this is a major asset because it virtually eliminates spam bot comments without requiring CAPTCHA puzzles.

What if my audience does not use GitHub?

If you run a mainstream consumer blog where visitors don't have GitHub accounts, consider:

  • Embedding an open community forum like Flarum.
  • Directing users to a Facebook Community group (as seen on our Contact page).
  • Using a lightweight hosted form like Web3Forms for reader feedback.

Conclusion

You don't have to surrender your static website's speed, privacy, or security just to let readers leave comments. By integrating Giscus, your static blog gains high-speed, markdown-capable discussions with zero server upkeep.

Browse our Comments & Community Directory for more tools to engage your static website audience.

Series Complete: You've reached the end of the Static HTML Starter Series! If you want to revisit the full stack or save your favorite tools for future projects, head back to Part 1: A Blueprint for Beginners or share your finished site in the StaticStack Community.

Topics:

Discussion

Create a new discussion or reply to a comment below.

Loading discussion…

Back to All Articles Browse Comments & Community Tools Submit a Tool →