To add Astro comments to a static blog, use a comment system that runs outside your build: Giscus (backed by GitHub Discussions) is the most popular free choice for developer blogs, utterances uses GitHub Issues, Disqus and Hyvor Talk are hosted services for general audiences, and Remark42 or Cusdis can be self-hosted if you want to own the data. Load any of them lazily, only when the reader reaches the comments, so they don’t slow down the post.
This guide compares the options that work with Astro, shows how to embed one in a reusable component, and covers lazy loading, dark mode and view transitions.
Key Takeaways
- Astro has no built-in comments; every option is a third-party script or a self-hosted service.
- Giscus is free, ad-free and stores comments in GitHub Discussions, but readers need a GitHub account.
- For non-technical readers, a hosted service with guest or social login fits better.
- Load the widget with
IntersectionObserveror aclient:visibleisland so it costs nothing until it’s needed.- Social replies and webmentions are an alternative to on-page comments for small blogs.
Astro comment systems compared
| System | Storage | Reader login | Cost model | Self-host | Best for |
|---|---|---|---|---|---|
| Giscus | GitHub Discussions | GitHub | Free, open source | No (uses GitHub) | Developer blogs |
| utterances | GitHub Issues | GitHub | Free, open source | No (uses GitHub) | Minimal developer blogs |
| Disqus | Disqus | Disqus, social, guest | Free tier with ads; paid plans | No | General audiences, quick setup |
| Hyvor Talk | Hyvor | Email, social, SSO | Paid | No | Privacy-focused, no ads |
| Remark42 | Your server | Social, email, anonymous | Free, open source | Yes | Owning your data |
| Cusdis | Hosted or your server | None required | Free tier, open source | Yes | Lightweight comments |
| Webmentions / social replies | Other sites | Their own accounts | Free | Partly | IndieWeb, small blogs |
Pricing and plans change; check each provider for current terms.
Giscus
Giscus maps each blog post to a GitHub Discussion and shows the thread on your page. Setup takes a few minutes:
- Create a public GitHub repository for comments (or use the blog’s repo) and enable Discussions.
- Install the Giscus GitHub app on that repository.
- Use the configurator on giscus.app to get your
repo-idandcategory-id.
Then wrap it in a component:
---
// src/components/Comments.astro
interface Props {
term: string;
}
const { term } = Astro.props;
---
<section class="comments" aria-labelledby="comments-heading">
<h2 id="comments-heading">Comments</h2>
<div
class="giscus-mount"
data-repo="your-name/blog-comments"
data-repo-id="R_xxxxxxxx"
data-category="Comments"
data-category-id="DIC_xxxxxxxx"
data-term={term}
></div>
</section>
<script>
const mounts = document.querySelectorAll<HTMLElement>('.giscus-mount');
const load = (mount: HTMLElement) => {
const s = document.createElement('script');
s.src = 'https://giscus.app/client.js';
s.async = true;
s.crossOrigin = 'anonymous';
s.setAttribute('data-repo', mount.dataset.repo!);
s.setAttribute('data-repo-id', mount.dataset.repoId!);
s.setAttribute('data-category', mount.dataset.category!);
s.setAttribute('data-category-id', mount.dataset.categoryId!);
s.setAttribute('data-mapping', 'specific');
s.setAttribute('data-term', mount.dataset.term!);
s.setAttribute('data-theme', 'preferred_color_scheme');
s.setAttribute('data-loading', 'lazy');
mount.appendChild(s);
};
const observer = new IntersectionObserver((entries) => {
for (const entry of entries) {
if (entry.isIntersecting) {
load(entry.target as HTMLElement);
observer.unobserve(entry.target);
}
}
}, { rootMargin: '400px' });
mounts.forEach((m) => observer.observe(m));
</script>
Use it at the bottom of your post layout:
---
// src/layouts/PostLayout.astro
import Comments from '../components/Comments.astro';
const { post } = Astro.props;
---
<article>
<slot />
</article>
<Comments term={post.id} />
Mapping by specific term (the post id) means the thread survives title changes and URL restructures, unlike pathname mapping. The script loads only when the comments section is within 400 px of the viewport.
The trade-off: readers need a GitHub account to comment. For a blog about code, that’s usually fine. For a recipe or travel blog, it isn’t.
utterances
utterances is the predecessor to Giscus and uses GitHub Issues instead of Discussions. The embed is a single script tag with repo, issue-term and theme attributes. It’s lighter on features (no reactions on the main post, no nested replies) but very simple. Most new sites choose Giscus, since Discussions support threaded replies.
Disqus and other hosted services
Disqus is the most familiar hosted option. Readers can comment with a Disqus account, social login or as guests (if you allow it), and moderation happens in its dashboard. The embed loads a large script, and the free tier shows ads, which matters for both performance and privacy. If you use it, lazy load it exactly as above and mention it in your privacy policy.
Hyvor Talk and similar paid services offer ad-free comments, guest commenting, moderation tools and privacy-friendly defaults. They suit business blogs where the audience isn’t on GitHub and ads aren’t acceptable.
Self-hosted comments: Remark42 and Cusdis
If you want the data on your own infrastructure:
- Remark42 is a self-hosted comment engine with social and email login, anonymous comments, moderation and import from Disqus. It runs as a Docker container on a small server.
- Cusdis is a lightweight, open-source option you can self-host or use as a hosted service. Readers comment without logging in; you approve comments in a dashboard.
Both embed with a script and a container element, so the component pattern above works: replace the Giscus script with theirs. Running them means maintaining a server, which is the work a static Astro blog otherwise avoids.
Comments without a widget
Some blogs skip on-page comments entirely:
- Social replies: link each post to a thread on Mastodon or Bluesky and display replies through their public APIs, either at build time or with a small client script.
- Webmentions: a service such as webmention.io receives mentions from other sites; you fetch and render them during the build or client-side.
- Email replies: a “Reply by email” link with the post title in the subject. It produces fewer, better responses and no moderation queue.
Fetching replies at build time keeps the page static but means new replies appear only after the next build.
Making comments work with view transitions
If your blog uses <ClientRouter />, the script above runs once, on the first page, and comments won’t load on posts you navigate to. Wrap the setup in the astro:page-load event:
<script>
document.addEventListener('astro:page-load', () => {
const mount = document.querySelector<HTMLElement>('.giscus-mount');
if (!mount || mount.dataset.loaded) return;
mount.dataset.loaded = 'true';
// ...create and append the Giscus script as above
});
</script>
Our Astro view transitions guide explains the lifecycle events.
Dark mode
Giscus accepts preferred_color_scheme to follow the operating system. If your site has a manual theme toggle, send the new theme to the Giscus iframe when it changes:
// src/scripts/theme.ts
export function setGiscusTheme(theme: 'light' | 'dark') {
const frame = document.querySelector<HTMLIFrameElement>('iframe.giscus-frame');
frame?.contentWindow?.postMessage(
{ giscus: { setConfig: { theme } } },
'https://giscus.app'
);
}
Most hosted services have a similar theme option or a reload-based approach. Our dark mode toggle guide shows the toggle itself.
Choosing comments for an Astro blog
- Developer audience, no budget: Giscus.
- General audience, quick setup: a hosted service such as Disqus or Hyvor Talk.
- You must own the data: Remark42 or self-hosted Cusdis.
- Small blog, low volume: social replies, webmentions or email.
Whatever you choose, load it lazily and keep it below the article so it never competes with the content. Our is Astro good for blogs article covers the other add-ons a static blog typically needs.
Komal blog themes keep post layouts as plain .astro files, so dropping in a comments component is a one-line change in the layout; browse blog and editorial themes or read the content docs. For Giscus options, see the Giscus documentation.
FAQ
How do I add comments to an Astro blog?
Pick a comment system such as Giscus, Disqus or Remark42, put its embed code in an .astro component, and render that component at the end of your post layout. Load the script lazily so it doesn’t slow down the page.
What is the best free comment system for Astro?
For developer blogs, Giscus: it’s free, ad-free and stores comments in GitHub Discussions. For general audiences who don’t have GitHub accounts, a self-hosted option like Remark42 or Cusdis avoids fees, at the cost of running a server.
Do comments affect Astro site performance?
They can. Comment widgets load third-party scripts and iframes. Loading them only when the reader scrolls near the comments, with IntersectionObserver or a client:visible island, keeps them out of the initial page load.
Are Giscus comments indexed by search engines?
Generally not as part of your page. Giscus renders comments inside an iframe loaded with JavaScript, so search engines treat them as separate content. The post itself remains fully indexable static HTML.
Can I moderate comments on a static Astro site?
Yes. Moderation happens in the comment system, not in Astro: GitHub Discussions for Giscus, the provider’s dashboard for hosted services, or the admin interface of a self-hosted engine like Remark42.