Comments (Twikoo)
ModernDuang integrates with Twikoo, a lightweight, privacy-focused, self-hosted comment system. Twikoo stores comment data in your own cloud backend and does not inject third-party trackers or advertisements.
Configuration
Comments are configured under the comments key in _config.modernduang.yml:
When envId is left empty (''), comments are completely disabled across the entire site — no comment section is rendered on any post.
Getting Your envId
The envId is the URL of your deployed Twikoo backend. The setup process depends on where you deploy:
Tencent Cloud (CloudBase)
Twikoo natively supports Tencent CloudBase. Follow the official Twikoo documentation to:
- Create a CloudBase environment
- Deploy the Twikoo cloud function
- Obtain the environment ID URL
Your envId will look like:
Vercel + MongoDB
Twikoo can also be deployed on Vercel with a MongoDB Atlas database. After deployment, your envId is your Vercel deployment URL:
Self-Hosted (Docker)
If you run Twikoo via Docker, the envId is the URL where your Twikoo instance is accessible:
Refer to the Twikoo documentation for the most up-to-date deployment instructions.
Region Configuration
The region property is only relevant when using Tencent CloudBase. It specifies the geographical region of your CloudBase environment:
If you deploy Twikoo on Vercel, Docker, or another non-CloudBase platform, the region setting is ignored — you can leave it as-is.
How It Appears
When enabled, each post page displays a comment section below the article content. The section includes:
- A comment count header (e.g., "Comments (5)")
- A comment input form for visitors to leave new comments
- A threaded comment list with avatars, names, timestamps, and reply buttons
- Markdown support in comments (code blocks, bold, links, etc.)
The comment section is styled to match the theme's claymorphism design with soft shadows, rounded corners, and smooth transitions.
Per-Post Comment Control
You can disable comments on individual posts by adding comment: false to the post's frontmatter:
When comment: false, the entire comment section (including the comment count and input form) is hidden for that specific post.
Conversely, if you have disabled comments globally (by setting envId: '') but want to enable them for a specific post:
Note: Setting
comment: truein a post's frontmatter has no effect ifenvIdis empty — the global setting takes precedence.
Updating the Twikoo Frontend Version
The theme hardcodes the Twikoo CDN version in layout/partials/comments/twikoo.ejs. To update to a newer version:
- Open
themes/modernduang/layout/partials/comments/twikoo.ejs - Find
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/twikoo.all.min.js" ...> - Replace
1.7.13with the latest version number
Note: Editing theme files directly will be lost when updating the theme. For a persistent override, copy the file to your site's
layout/partials/comments/directory first — Hexo will prioritize your site's copy over the theme's.
Complete Example
Once configured, rebuild your site:
Troubleshooting
Comments don't appear
- Verify
envIdis correctly set — it must be a full URL, not just an ID - Check that your Twikoo backend is running (visit the
envIdURL in a browser) - Ensure the post has
comment: true(or nocommentsetting at all) - Check browser console for CORS errors — your Twikoo backend must allow requests from your site's domain
Comments appear as a loading spinner
- The Twikoo JS library may be blocked by an ad blocker or network restriction
- If you use a custom domain, make sure it is correctly configured in your Twikoo backend
- Check that your site is served over HTTPS if your Twikoo backend requires HTTPS
Related Pages
- Footer & ICP Beian — Footer configuration including author attribution
- Navigation & Menus — Navigation bar setup
