• English
  • 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:

    comments:
      twikoo:
        envId: https://your-twikoo-envid
        region: ap-shanghai
    PropertyTypeDefaultDescription
    twikoo.envIdstring''Your Twikoo environment ID (full URL to your Twikoo backend)
    twikoo.regionstring'ap-shanghai'Cloud region for the Twikoo service

    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:

    1. Create a CloudBase environment
    2. Deploy the Twikoo cloud function
    3. Obtain the environment ID URL

    Your envId will look like:

    https://your-env-id.service.tcloudbase.com

    Vercel + MongoDB

    Twikoo can also be deployed on Vercel with a MongoDB Atlas database. After deployment, your envId is your Vercel deployment URL:

    https://twikoo-yourname.vercel.app

    Self-Hosted (Docker)

    If you run Twikoo via Docker, the envId is the URL where your Twikoo instance is accessible:

    https://twikoo.yourdomain.com

    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:

    Region CodeLocation
    ap-shanghaiShanghai (default)
    ap-guangzhouGuangzhou
    ap-beijingBeijing
    ap-chengduChengdu

    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:

    ---
    title: My Private Draft
    date: 2025-01-15
    comment: false
    ---
    
    This post will not display a comment section.

    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:

    ---
    title: Discussion Post
    date: 2025-01-15
    comment: true
    ---

    Note: Setting comment: true in a post's frontmatter has no effect if envId is 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:

    1. Open themes/modernduang/layout/partials/comments/twikoo.ejs
    2. Find <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/twikoo.all.min.js" ...>
    3. Replace 1.7.13 with 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

    # _config.modernduang.yml
    comments:
      twikoo:
        envId: https://my-blog-abc123.service.tcloudbase.com
        region: ap-shanghai

    Once configured, rebuild your site:

    hexo clean && hexo generate

    Troubleshooting

    Comments don't appear

    • Verify envId is correctly set — it must be a full URL, not just an ID
    • Check that your Twikoo backend is running (visit the envId URL in a browser)
    • Ensure the post has comment: true (or no comment setting 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