logo
0
0
WeChat Login
Huazie<huazie.lgh@gmail.com>
Mod: 添加模板引擎支持描述

Hexo Comments Giscus

NPM version Required Node.js version Required Hexo version License GitHub Repo stars

Easily integrate the Giscus comment system into your Hexo blog, a modern comment solution based on GitHub Discussions.

中文说明/Chinese Documentation

Features

FeatureDescriptionAdvantages
GitHub DiscussionsBased on GitHub Discussions, no database requiredZero maintenance cost, high availability
Secure & ReliableFully open source, no ads or trackingProtects user privacy, transparent and trustworthy
Theme SwitchingSupports light/dark theme auto-switchingPerfectly adapts to various theme styles
Responsive DesignAdapts to various device screensMobile-friendly user experience
Instant LoadingSupports lazy loading and loading animationsOptimizes page performance
Multi-language SupportSupports multiple interface languagesInternationalization friendly
Easy ConfigurationSimple YAML configurationQuick setup, flexible customization

Quick Start

Installation

# 1. Install multi-comment system core plugin (required) npm install hexo-generator-comments --save # 2. Install Giscus comment plugin npm install hexo-comments-giscus --save

Note: hexo-comments-giscus needs to be used with hexo-generator-comments More info: hexo-generator-comments

Configuration Guide

Basic Configuration

Add the following content to your Hexo site configuration _config.yml or theme configuration _config.yml, _config.[theme].yml:

giscus: # Enable Giscus comment system enable: false # Show loading animation loading: true # GitHub repository, format: username/repo-name repo: your-username/your-repo-name # GitHub repository unique ID repo_id: your-repo-id # GitHub Discussions category name category: General # Discussions category unique ID category_id: your-category-id # GitHub discussion mapping rule mapping: pathname # Specific term when mapping is 'specific' term: # Enable strict title matching strict: 0 # Enable reactions on main post reactions_enabled: 1 # Emit discussion metadata emit_metadata: 0 # Light theme theme: light # Dark theme dark: dark # Comment section language lang: # Comment input position input_position: bottom # Lazy load comments data_loading: lazy

Important: Replace the placeholders in the configuration with your actual GitHub repository information

Configuration Options Details

OptionTypeDefaultRequiredDescription
enableBooleanfalseYesEnable Giscus comment system
loadingBooleantrueYesShow comment loading animation
repoString-YesGitHub repository, format: username/repo-name
repo_idString-YesGitHub repository unique ID
categoryString-YesGitHub Discussions category name
category_idString-YesDiscussions category unique ID
mappingStringpathnameYesGitHub discussion mapping rule
termString-NoSpecific term when mapping is 'specific'
strictNumber0YesEnable strict title matching
reactions_enabledNumber1YesEnable reactions on main post
emit_metadataNumber0YesEmit discussion metadata
themeStringlightYesLight mode theme
darkStringdarkYesDark mode theme
langStringnavigator.languageNoComment section language
input_positionStringbottomNoComment input position
data_loadingStringlazyNoLazy load comments

Advanced Configuration Options

mapping Methods

ValueDescriptionUse Cases
pathnameUse page path as discussion titleRecommended, suitable for most scenarios
urlUse full page URL as discussion titleWhen domain information is needed
titleUse page title as discussion titleWhen you want more friendly discussion titles
og:titleUse page Open Graph titleSEO optimization scenarios
specificUse specific term as titleCustom identifiers

Theme Style Options

Theme NameCharacteristics
lightStandard light theme
light_high_contrastHigh contrast light theme
light_protanopiaProtanopia-friendly light theme
light_tritanopiaTritanopia-friendly light theme
darkStandard dark theme
dark_high_contrastHigh contrast dark theme
dark_protanopiaProtanopia-friendly dark theme
dark_tritanopiaTritanopia-friendly dark theme
dark_dimmedDimmed dark theme
preferred_color_schemeAuto-follow system theme
transparent_darkTransparent dark theme
noborder_lightBorderless light theme
noborder_darkBorderless dark theme
noborder_grayBorderless gray theme
cobaltCobalt blue theme
purple_darkPurple dark theme

Language Options

Language CodeLanguage Name
zh-CNSimplified Chinese
zh-TWTraditional Chinese
enEnglish
es-ESSpanish
frFrench
ruRussian
......

Supported Template Engines

This plugin supports all Hexo themes using the following template engines:

Template EngineFile ExtensionSupport Status
EJS.ejs✅ Fully Supported
Nunjucks.njk✅ Fully Supported
JSX + Inferno.jsx✅ Fully Supported

Prerequisites

Before getting started, please ensure the following requirements are met:

1. GitHub Repository Preparation

  • Have a public GitHub repository
  • Discussions feature is enabled for the repository

2. Install Giscus App

  • Visit Giscus GitHub App
  • Click "Install" and select your repository
  • Authorize Giscus to access your repository

3. Get Configuration Parameters

Note: Giscus App only requires read-write permissions for Discussions, very secure

How It Works

Detailed Process

  1. Page Loading: Visitor opens the page, Giscus script starts working
  2. Search Discussion: Search for related discussions in the specified repository's Discussions based on configured mapping
  3. Display Comments: If corresponding discussion is found, display comments from it
  4. Create Discussion: When commenting for the first time, automatically create a new discussion
  5. GitHub Login: Visitors need a GitHub account to participate in comments

System Requirements

DependencyVersion RequirementDescription
Node.js>= 14.0.0JavaScript runtime environment
Hexo>= 5.3.0Static site generator
GitHub RepositoryPublic repositoryStores comment data

Related Links

Official Resources

Hexo Documentation

Related Plugins

License

This project is open source under the MIT license.