Hexo 常用命令参考手册
本文档总结了 Hexo 博客框架最常用的命令行操作,帮助你更高效地管理博客。
一、基础命令
1.1 安装 Hexo CLI
1 2
| npm install -g hexo-cli
|
1.2 初始化项目
1 2 3 4 5
| hexo init [folder]
hexo init
|
1.3 查看版本信息
二、内容创建命令
2.1 创建新文章
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| hexo new [layout] <title>
hexo new "我的第一篇文章"
hexo new draft "草稿文章"
hexo new page "关于我"
hexo new page --path about/me "About me"
|
常用参数:
-p, --path: 自定义文件路径
-r, --replace: 替换现有文件
-s, --slug: 自定义 URL slug
2.2 发布草稿
1 2 3 4 5
| hexo publish [layout] <filename>
hexo publish draft "草稿文章"
|
三、生成与预览命令
3.1 生成静态文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| hexo generate
hexo g
hexo generate --deploy hexo g -d
hexo generate --watch hexo g -w
hexo generate --force hexo g -f
hexo generate --bail hexo g -b
hexo generate --concurrency 10 hexo g -c 10
|
3.2 启动本地服务器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| hexo server
hexo s
hexo server -p 8080 hexo s -p 5000
hexo server --static hexo s -s
hexo server --log "common"
hexo server --draft hexo s -d
|
四、部署命令
4.1 部署网站
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| hexo deploy
hexo d
hexo deploy --generate hexo d -g
hexo clean && hexo generate && hexo deploy
hexo clean && hexo g -d
|
五、清理与维护命令
5.1 清理缓存
5.2 列出路由
1 2 3 4 5 6 7
| hexo list <type>
hexo list post hexo list page hexo list route
|
六、高级命令
6.1 渲染文件
1 2 3 4 5 6
| hexo render <file1> [file2] ...
hexo render index.md -o output/ hexo render file.md -o _public
|
6.2 迁移内容
6.3 配置管理
1 2 3 4 5 6 7 8 9 10 11
| hexo config [key]
hexo config theme
hexo config [key] [value]
hexo config theme landscape
|
七、全局选项
这些选项可以与任何命令一起使用:
7.1 自定义配置文件
1 2 3 4 5 6 7 8
| hexo --config custom.yml
hexo --config custom.yml,custom2.json
hexo server --config custom.yml
|
7.2 安全模式
7.3 调试模式
7.4 静默模式
7.5 显示草稿
7.6 自定义工作目录
1 2
| hexo --cwd /path/to/cwd
|
八、常用命令组合
8.1 完整的发布流程
1 2 3 4 5
| hexo clean && hexo generate && hexo deploy
hexo clean && hexo g -d
|
8.2 开发流程
1 2
| hexo clean && hexo server --draft
|
8.3 快速预览
8.4 调试模式生成
九、命令别名速查表
| 完整命令 |
简写 |
说明 |
hexo generate |
hexo g |
生成静态文件 |
hexo server |
hexo s |
启动本地服务器 |
hexo deploy |
hexo d |
部署网站 |
hexo new |
hexo n |
创建新文章 |
hexo --draft |
hexo -d |
显示草稿 |
hexo --generate |
hexo -g |
生成(用于部署命令) |
十、常见问题解决
10.1 清除缓存问题
如果遇到页面不更新的问题:
1 2
| hexo clean hexo generate
|
10.2 端口占用
如果 4000 端口被占用:
10.3 插件问题排查
如果怀疑是插件导致的问题:
十一、推荐工作流
日常写作流程
1 2 3 4 5 6 7 8 9 10
| hexo new "文章标题"
hexo clean && hexo server --draft
hexo clean && hexo g -d
|
主题开发流程
1 2 3 4 5 6
| hexo clean && hexo server --watch
|
参考资源
提示: 将此文档保存为书签,随时查阅 Hexo 命令!