Giscus Comments
Integrate GitHub Discussions-powered comments into your Jekyll site using Giscus - a modern, privacy-friendly alternative to Disqus.
Giscus Comments
Add a GitHub Discussions-powered comment system to your Jekyll site with automatic theme detection and privacy-friendly design.
Overview
Giscus is a comments system powered by GitHub Discussions. Unlike traditional services like Disqus, Giscus:
- Requires no database — comments are stored in GitHub Discussions
- Respects privacy — no tracking, no ads
- Supports reactions — GitHub emoji reactions on comments
- Auto theme detection — matches your site’s light/dark mode
- Free and open source — MIT licensed
Prerequisites
Before setting up Giscus, ensure you have:
- A public GitHub repository for your Jekyll site
- GitHub Discussions enabled on the repository
- The Giscus app installed on your repository
Installation
Step 1: Enable GitHub Discussions
- Go to your repository on GitHub
- Navigate to Settings → General
- Scroll to Features section
- Check Discussions
Step 2: Install Giscus App
- Visit https://github.com/apps/giscus
- Click Install
- Select your repository
- Authorize the installation
Step 3: Get Configuration Values
- Visit https://giscus.app/
- Enter your repository name (e.g.,
username/repo-name) - Select your preferred settings:
- Page ↔ Discussions Mapping:
pathname(recommended) - Discussion Category: Choose or create a category like “Comments”
- Features: Enable reactions, lazy loading as desired
- Page ↔ Discussions Mapping:
- Copy the
data-repo-idanddata-category-idvalues
Step 4: Configure Jekyll
Add the Giscus configuration to your _config.yml. The theme reads exactly
three keys — enabled, data-repo-id, and data-category-id:
# Giscus Comment System Configuration
giscus:
enabled: true
data-repo-id: "YOUR_REPO_ID"
data-category-id: "YOUR_CATEGORY_ID"
The data-repo value is filled in automatically from site.repository
(set near the top of _config.yml), so you don’t repeat the owner/repo here.
Verify it works
The comment section renders at the bottom of the article, note, and
notebook layouts. The gating differs slightly by layout:
article.htmlrenders comments whensite.giscusexists (the block is present).note.htmlandnotebook.htmlrender comments whensite.giscus.enabledistrue.
Keeping enabled: true in the config block satisfies all three.
-
Build the site with the dev config:
docker-compose exec -T jekyll bundle exec jekyll build \ --config '_config.yml,_config_dev.yml' -
Confirm the Giscus script is emitted on a built post and your IDs were interpolated (no empty attributes):
grep -A1 'giscus.app/client.js' _site/**/index.html | grep -m1 data-repo-idExpected: a
data-repo-id="..."attribute carrying your real ID. An emptydata-repo-id=""means thegiscusblock is missing or the key is misspelled. -
Serve the site (
docker-compose up) and open a post. The Giscus widget loads from GitHub, so it only fully renders on a public, deployed URL — onlocalhost:4000you can confirm the<script src="https://giscus.app/client.js">tag is present even though the embedded thread won’t load.
Configuration Options
Data attributes
The theme’s include lives at _includes/content/giscus.html. Only the first
three attributes below are wired to your _config.yml; the rest are fixed in
the include. To change a fixed attribute you must edit
_includes/content/giscus.html directly.
| Attribute | Source | Value |
|---|---|---|
data-repo |
Config | {{ site.repository }} |
data-repo-id |
Config | {{ site.giscus.data-repo-id }} (required) |
data-category-id |
Config | {{ site.giscus.data-category-id }} (required) |
data-mapping |
Fixed in include | pathname |
data-strict |
Fixed in include | 1 |
data-reactions-enabled |
Fixed in include | 1 |
data-emit-metadata |
Fixed in include | 0 |
data-input-position |
Fixed in include | top |
data-theme |
Fixed in include | preferred_color_scheme |
data-lang |
Fixed in include | en |
Theme options
The include ships with data-theme="preferred_color_scheme" (auto light/dark).
To use a different theme, edit data-theme in _includes/content/giscus.html
to one of:
| Value | Description |
|---|---|
preferred_color_scheme |
Auto-detect from browser settings (default) |
light |
Always light mode |
dark |
Always dark mode |
dark_dimmed |
Dimmed dark mode |
transparent_dark |
Transparent dark background |
| Custom URL | Load custom CSS theme |
Disabling comments per page
To disable comments on specific pages, add to front matter:
---
title: "Page Without Comments"
comments: false
---
Migration from Disqus
If migrating from Disqus:
- Export Disqus comments (optional — for archival)
- Remove Disqus scripts from your templates
- Delete Disqus configuration from
_config.yml - Follow the installation steps above
- Note: Existing Disqus comments won’t transfer to Giscus
Troubleshooting
Comments Not Appearing
- Check repository visibility — must be public
- Verify Discussions are enabled on the repository
- Confirm Giscus app is installed on the repository
- Validate configuration IDs match your repository
Theme Not Matching
The include uses data-theme="preferred_color_scheme", which follows the
browser’s light/dark preference. To force a theme, edit data-theme in
_includes/content/giscus.html:
<!-- Force a specific theme -->
data-theme="light"
<!-- Or load a custom CSS theme -->
data-theme="https://yoursite.com/giscus-custom.css"
Multiple Comment Threads
If pages are creating duplicate discussions:
- The include already ships with
data-strict="1"anddata-mapping="pathname"— confirm you haven’t changed them in_includes/content/giscus.html - Verify page URLs are stable (no trailing-slash issues), since
pathnamemapping keys discussions to the URL path
Best Practices
- Pathname mapping and strict mode are on by default — the include already sets
data-mapping="pathname"anddata-strict="1", which is the most reliable setup for Jekyll sites - Create a dedicated category — keeps comments organized
- Test locally — the embedded thread won’t load on localhost, but verify the
https://giscus.app/client.jsscript tag is present - Disable per page when needed — set
comments: falsein a page’s front matter (works in thearticle,note, andnotebooklayouts)
Further Reading
This guide is part of the Zer0-Mistakes Jekyll Theme documentation.
See also
- [[Features]]
- [[PostHog Analytics]]