| name | hugo-papermod-manager |
| description | Hugo静态网站和PaperMod主题管理工具。当用户需要操作Hugo网站、管理PaperMod主题配置、创建内容、运行开发服务器或部署网站时使用此skill。特别适用于使用Hugo和PaperMod主题的个人博客、学术网站或作品集网站。 |
Hugo & PaperMod主题管理器
概述
此skill提供Hugo静态网站生成器和PaperMod主题的常用命令、配置指南和工作流程。涵盖本地开发、内容创建、主题定制、构建部署等完整生命周期管理。
快速开始
环境检查
hugo version
git submodule status
git submodule update --init --recursive
开发服务器
hugo server
hugo server -D
hugo server -p 8080
hugo && hugo server --environment production
内容管理
hugo new posts/my-new-post.md
hugo new projects/my-new-project.md
hugo new tutorials/my-tutorial.md
hugo new posts/my-post.md --kind post
常用命令
构建网站
hugo
hugo --minify
hugo --environment production
hugo --gc
内容操作
hugo list all
hugo list drafts
hugo list expired
hugo list future
主题管理
cd themes/PaperMod
git pull origin main
cd ../..
git submodule update --remote themes/PaperMod
git -C themes/PaperMod log -1 --oneline
PaperMod主题配置
主题设置参考
PaperMod主题支持以下常见配置(在hugo.yaml中):
params:
ShowReadingTime: true
ShowShareButtons: true
ShowCodeCopyButtons: true
comments: true
ShowToc: true
ShowBreadCrumbs: true
ShowPostNavLinks: true
ShowRelated: true
ShowWordCount: true
enableSearch: true
defaultDark: false
multilingualMode: true
自定义布局
如需覆盖主题模板,将文件复制到layouts目录:
cp themes/PaperMod/layouts/_default/single.html layouts/_default/
cp themes/PaperMod/layouts/_default/list.html layouts/_default/
cp themes/PaperMod/layouts/_default/home.html layouts/_default/
部署工作流
GitHub Pages部署
hugo --minify
git add .
git commit -m "更新网站内容"
git push origin main
gh workflow run hugo.yml
本地预览构建结果
hugo --minify
cd public
python -m http.server 8000
npx serve -p 8000
故障排除
常见问题
-
主题未加载:确保主题子模块已初始化
git submodule update --init --recursive
-
页面未更新:清理Hugo缓存
hugo --gc
rm -rf public resources
-
图片未显示:确保图片在static目录或使用相对路径
-
构建错误:检查YAML语法和front matter格式
调试命令
hugo --verbose
hugo --debug
hugo --buildDrafts --buildExpired --buildFuture
内容模板参考
博客文章模板
---
title: "文章标题"
date: 2026-01-08T10:30:00+08:00
draft: true
tags: ["标签1", "标签2"]
categories: ["分类"]
summary: "文章摘要"
showToc: true
tocOpen: true
---
正文内容...
项目页面模板
---
title: "项目名称"
date: 2026-01-08
draft: false
project: true
description: "项目描述"
tags: ["技术栈", "类别"]
links:
- name: "GitHub"
url: "https://github.com/username/repo"
- name: "演示"
url: "https://demo.example.com"
featured: true
---
项目详情...
工具脚本
此skill包含多个实用脚本,可简化Hugo网站管理工作:
开发服务器脚本 (scripts/start-dev-server.sh)
./scripts/start-dev-server.sh
./scripts/start-dev-server.sh --port 8080 --bind 0.0.0.0 --with-drafts --open-browser
./scripts/start-dev-server.sh --help
生产构建脚本 (scripts/build-production.sh)
./scripts/build-production.sh
./scripts/build-production.sh --clean --verbose
./scripts/build-production.sh --performance --git-info
./scripts/build-production.sh --help
内容创建脚本 (scripts/create-content.sh)
./scripts/create-content.sh post "我的新文章" --tags "hugo,博客" --categories "技术"
./scripts/create-content.sh project "我的项目" --publish --tags "react,nodejs"
./scripts/create-content.sh tutorial "Hugo入门指南" --output-dir content/tutorials --edit
./scripts/create-content.sh --help
脚本使用说明
- 确保脚本有执行权限:
chmod +x scripts/*.sh
- 在项目根目录运行脚本
- 所有脚本都支持
--help 查看详细用法
- 脚本会检查Hugo是否安装并提供友好错误信息
参考文档
PaperMod配置参考 (references/papermod-config-reference.md)
包含PaperMod主题所有配置参数的详细说明,包括:
- 基本设置和显示功能
- 评论系统配置(Disqus、Utterances、Remark42)
- 搜索功能配置(Fuse、Algolia)
- 社交媒体和图片配置
- 多语言支持和高级配置
Hugo命令参考 (references/hugo-commands-reference.md)
完整的Hugo命令参考,包括:
- 服务器和构建命令
- 内容管理和列表命令
- 配置调试和模块管理
- 部署优化和性能调优
- 故障排除和环境变量
模板资源
内容模板 (assets/)
post-template.md:博客文章模板,包含完整front matter和结构化内容
project-template.md:项目页面模板,包含技术栈、部署说明、项目成果等
使用模板:
cp assets/post-template.md content/posts/my-new-post.md
sed -i 's/{{title}}/我的文章标题/g' content/posts/my-new-post.md
最佳实践
- 版本控制:将整个Hugo项目(包括主题子模块)提交到Git
- 内容组织:使用清晰的目录结构(posts/, projects/, tutorials/等)
- 图片管理:将图片放在static/images/目录并使用相对路径
- 定期更新:定期更新Hugo和PaperMod主题版本
- 备份配置:备份hugo.yaml和自定义布局文件
扩展阅读