深色/浅色主题切换,支持系统偏好检测与 localStorage 记忆
hugo-themes-zhi — Hugo 博客模板
作者 mickeyzzc
Zhi 是一个基于 Hugo 的极简博客主题,支持深色/浅色模式、MathJax 公式、Mermaid 图表、图片灯箱与代码复制,全部资源通过 Hugo Pipes 处理,无需 webpack 或 Vite 等外部构建工具。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 3
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
MathJax 与 Mermaid 按需自动加载,Mermaid 支持 v11+ 扩展节点形状、classDef 与 ELK 布局
代码块带语言标签与复制按钮,使用 Hugo 内置 Chroma 高亮
Bilibili/YouTube 视频短代码,支持按访问者时区自动切换平台并可手动切换
CSS/JS 全部经 Hugo Pipes 处理(resources.Get → minify → fingerprint),无需 webpack/vite
内置系列分类、多语言切换、归档、友链与标签云等页面模板
模板详细介绍
Zhi 是面向 Hugo 站点的博客主题,定位为极简风格,内容区最大宽度 768px,采用移动优先的响应式布局。主题通过配置项按需开启功能:代码高亮、MathJax 数学公式、Mermaid 图表、深色/浅色切换、图片灯箱、自定义统计与系列(series)分类。MathJax 与 Mermaid 在页面内容中出现对应标记时自动加载,Mermaid 支持 v11+ 的扩展节点形状、classDef 样式与 ELK 布局等特性。视频短代码可嵌入 Bilibili 或 YouTube,同时提供两个平台 ID 时按访问者时区自动选择播放源,也允许手动切换。主题内置多语言切换与翻译链接、系列文章的步骤式布局与排序切换,以及归档、友链、标签云等页面模板。样式与脚本全部经 Hugo Pipes 的 resources.Get、minify、fingerprint 流程处理,不依赖 webpack/vite;主题色以 CSS 自定义属性定义,可在站点自有 CSS 中覆盖。使用要求 Hugo 0.146.0 及以上版本,非 extended 版本亦可。仓库提供中英双语文档,涵盖功能、内容与配置说明。演示站点为 www.mickeyzzc.tech。
适合你的项目吗?
适用场景
- 用 Hugo 搭建个人技术博客并撰写含公式或流程图的长文
- 需要同时面向国内与海外读者嵌入 Bilibili 或 YouTube 视频
- 维护多语言博客并希望语言间自动关联翻译页面
- 将文章按系列组织,需要步骤式导航与排序切换
适合人群
- 使用 Hugo 0.146.0 及以上版本、偏好极简阅读版式的博客作者
- 希望不引入 Node 构建链、仅用 Hugo 自身工具链完成资源处理的站点
- 需要数学公式、Mermaid 图表与代码高亮等技术写作场景
- 需要深色模式、图片灯箱与多语言支持的站点
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
要求 Hugo ≥ 0.146.0,非 extended 版本也可使用
- 2
推荐以 Hugo Module 方式导入 github.com/mickeyzzc/hugo-theme-zhi,也可 git clone 到 themes/zhi 并设置 theme = 'zhi'
- 3
在 hugo.toml 的 [params.features] 中按需开启 codeHighlight、mathJax、mermaid、themeSwitch、lightbox、analytics、series 等开关
- 4
系列功能需在 [taxonomies] 中配置 series = "series"
- 5
主题色可在站点自有 CSS 中覆盖 assets/css/components/theme.css 定义的 CSS 变量
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
https://github.com/mickeyzzc/hugo-themes-zhi/blob/main/LICENSEhttps://github.com/mickeyzzc/hugo-themes-zhi/blob/main/README.mdPermission is hereby granted, free of charge
许可证原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-01。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 80 / 100
- 技术栈
- Hugo
- 网站类型
- 博客
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-09-23
- 截图检查日期
- 2026-10-01
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Hugo。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: a54bf74d83777c25b22a79b0b66772fe64172094e748b12e05156c22ab88d230
2026-10-01T14:20:39.520Z
来源文件 / 仓库[**English**](README.md) | [中文](README.zh.md)
# Zhi
A minimal Hugo blog theme with dark/light mode, MathJax, Mermaid diagrams, Bilibili/YouTube video shortcodes, image lightbox, and code copy — built with pure Hugo Pipes, zero external build tools.
     
## Features
- **Dark / Light Theme** — Toggle with system preference detection and `localStorage` persistence → [docs](docs/en/features.md#theme-switch)
- **Syntax Highlighting** — Hugo's built-in Chroma with copy button and language label → [docs](docs/en/content.md#code-highlight)
- **MathJax 3** — Auto-loaded when `$...$` or `$$...$$` detected in page content → [docs](docs/en/content.md#mathjax)
- **Mermaid v11+ Diagrams** — Auto-loaded when ` ```mermaid ` code blocks exist; supports expanded node shapes (`@{ shape: ... }`), `classDef` styling, ELK layout, architecture/kanban diagrams; theme-aware (dark/light) → [docs](docs/en/content.md#mermaid)
- **Video Shortcode** — Embed Bilibili or YouTube with automatic geo-switching (timezone-based) and manual toggle → [docs](docs/en/content.md#video)
- **Image Lightbox** — Click any article image to view full-size overlay → [docs](docs/en/features.md#image-lightbox)
- **Responsive Design** — Mobile-first, max-width `768px` content area
- **Custom Analytics** — Configurable endpoint with sampling support → [docs](docs/en/configuration.md#analytics)
- **Hugo Pipes** — All CSS/JS processed via `resources.Get` → `minify` → `fingerprint`, no webpack/vite
- **Multilingual / i18n** — Language switcher with automatic translation linking → [docs](docs/en/features.md#language-switcher)
- **Series Taxonomy** — Post series with stepper layout, sort toggle, and weight-based ordering → [docs](docs/en/features.md#series)
## Requirements
- Hugo **≥ 0.146.0** (non-extended is fine)
## Quick Start
### As a Hugo Theme Module (recommended)
In your site's `hugo.toml`:
```toml
[module]
[[module.imports]]
path = "github.com/mickeyzzc/hugo-theme-zhi"
```
### As a Git Clone
```bash
git clone https://github.com/mickeyzzc/hugo-theme-zhi.git themes/zhi
```
Then in your site's `hugo.toml`:
```toml
theme = 'zhi'
```
## Configuration
```toml
[params.features]
codeHighlight = true # Syntax highlighting
mathJax = true # Math rendering ($...$, $$...$$)
mermaid = true # Mermaid diagrams
themeSwitch = true # Dark/light toggle button
lightbox = true # Click-to-zoom images
analytics = true # Custom analytics endpoint
series = true # Post series with sort toggle
[params.analytics]
provider = "custom"
endpoint = "/metrics"
siteId = ""
sampleRate = 100
[params.video]
defaultPlatform = "bilibili" # "bilibili" or "youtube"
showSwitch = true # Show platform toggle button
[params.theme]
default = "auto" # "auto", "light", or "dark"
}
[taxonomies]
series = "series"
```
## Documentation
Comprehensive bilingual documentation for all features:
| Category | English | 中文 |
|----------|---------|------|
| Features | [docs](docs/en/features.md) | [文档](docs/zh-cn/features.md) |
| Content | [docs](docs/en/content.md) | [文档](docs/zh-cn/content.md) |
| Configuration | [docs](docs/en/configuration.md) | [文档](docs/zh-cn/configuration.md) |
## Usage
> For complete documentation, see [Documentation](#documentation).
{{</* video bilibili="BV1xx411c7mD" youtube="dQw4w9WgXcQ" title="Demo Video" */>}}
```
Embed Bilibili and/or YouTube videos. When both IDs are provided, the player auto-selects based on timezone (China → Bilibili, else → config default). Users can manually switch platforms.
### Mermaid Diagrams (v11+)
Use a fenced code block with the `mermaid` language. Supports all Mermaid v11+ features including expanded node shapes and `classDef` styling:
~~~markdown
```mermaid
graph TD
A@{ shape: doc, label: "Document" } --> B@{ shape: diam, label: "Decision" }
B -->|Yes| C@{ shape: hex, label: "Process" }
B -->|No| D@{ shape: cyl, label: "Database" }
classDef primary fill:#e1f5fe,stroke:#0288d1
classDef warn fill:#fff3e0,stroke:#ef6c00
class A,C primary
class B,D warn
```
~~~
Supported diagram types: `flowchart`, `sequence`, `class`, `state`, `ER`, `gantt`, `pie`, `mindmap`, `timeline`, `gitgraph`, `architecture` (v11.1+), `kanban` (v11.0+), and more.
### Math / LaTeX
Inline: `$E = mc^2$`
Display:
```markdown
$$
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
$$
```
### Code Blocks
All fenced code blocks automatically get:
- Language label (top-left)
- Copy button (top-right)
- Hugo Chroma syntax highlighting
```markdown
```python
def hello():
print("Hello, World!")
```
```
### Menus
```toml
[[menus.main]]
name = 'Home'
pageRef = '/'
weight = 10
[[menus.main]]
name = 'Posts'
pageRef = '/posts'
weight = 20
[[menus.main]]
name = 'Series'
pageRef = '/series'
weight = 30
```
### Social Links
```toml
[[params.social]]
name = "GitHub"
url = "https://github.com/yourusername"
[[params.social]]
name = "Twitter"
url = "https://twitter.com/yourusername"
```
## Project Structure
```
layouts/
├── _default/ # baseof.html, single.html, list.html, _markup/
├── _partials/ # Hugo 0.120+ partials (head, header, footer, menu, terms, lang-switch, greeting, tag-cloud)
├── partials/ # Legacy (mathjax.html, mermaid.html)
├── shortcodes/ # video.html
├── archives/ # Archives page
├── flinks/ # Friend links page
├── series/ # Series taxonomy pages
├── home.html, section.html, taxonomy.html, term.html
assets/
├── css/
│ ├── main.css # Aggregator via @import
│ └── components/ # Per-feature CSS modules
│ ├── theme.css # CSS variables (light + dark)
│ ├── header.css
│ ├── footer.css
│ ├── code.css
│ ├── video.css
│ ├── lightbox.css
│ ├── mermaid.css
│ ├── math.css
│ ├── lang-switch.css
│ ├── series.css
│ ├── greeting.css
│ └── tag-cloud.css
└── js/
├── main.js # Orchestrator (MathJax + Mermaid lazy-load)
├── code-copy.js # Copy button for code blocks
├── theme-toggle.js # Dark/light toggle with persistence
├── video-geo-switch.js # Bilibili/YouTube geo-switching
├── lightbox.js # Image lightbox overlay
├── sidebar.js
├── greeting.js
├── search.js
├── toc.js
├── reading-progress.js
├── back-to-top.js
├── donation.js
├── analytics.js
└── series-sort.js
```
## Development
```bash
# Start dev server with live reload
hugo server
# Production build
hugo --minify
# Run E2E tests
npx playwright test
```
## Theme System
Theme colors are defined as CSS custom properties in `assets/css/components/theme.css`:
```css
:root {
--bg: #ffffff;
--text: #222222;
--accent: #0066cc;
/* ... */
}
[data-theme="dark"] {
--bg: #1a1a1a;
--text: #e0e0e0;
--accent: #4da6ff;
/* ... */
}
```
Override these variables in your site's own CSS to customize colors.
## License
MIT
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

hugo-PaperMod
PaperMod 是 Hugo 生态里知名度较高的主题之一,定位很明确:给博客和轻量作品集站点提供一套干净、响应式的阅读界面。
Hugo · 作品集

LoveIt
❤️A clean, elegant but advanced blog theme for Hugo 一个简洁、优雅且高效的 Hugo 主题
Hugo · 博客

hugo-coder
A minimalist blog theme for hugo.
Hugo · 博客

blowfish
Personal Website & Blog Theme for Hugo
Hugo · 博客

hugo-paper
🪺 A simple, clean, customizable Hugo theme
Hugo · 博客

hextra
Hextra 是一个 Hugo 主题,定位在文档站与博客之间:既提供侧边栏导航、目录、面包屑、分页这类文档站结构,也能承载博客内容。
Hugo · 文档
