常用 Hexo 命令简写

1. 常用 Hexo 命令简写

完整命令 简写 说明
hexo new "文章标题" hexo n "文章标题" 新建一篇文章
hexo generate hexo g 生成静态文件
hexo server hexo s 启动本地服务器
hexo deploy hexo d 部署到远程仓库
hexo clean hexo c 清除缓存和生成的文件

示例:

1
2
3
hexo n "Hello World"  # 新建文章
hexo g && hexo s # 生成并启动本地服务器
hexo g && hexo d # 生成并部署

2. 组合命令

Hexo 支持 && 连接多个命令,例如:

1
2
hexo clean && hexo g && hexo s  # 清除缓存 -> 生成 -> 启动服务器
hexo clean && hexo g && hexo d # 清除缓存 -> 生成 -> 部署

3. -- 参数简写

完整参数 简写 说明
--draft -d 新建草稿
--config -c 指定配置文件
--port -p 指定服务器端口

示例:

1
2
hexo n -d "草稿文章"  # 新建草稿
hexo s -p 8080 # 在 8080 端口启动服务器

4. 其他快捷方式

  • 快速打开 Hexo 目录

    1
    cd ~/blog  # 进入你的 Hexo 博客目录(路径根据实际情况调整)
  • 快速编辑文章

    1
    code source/_posts/文章.md  # 用 VS Code 编辑文章(需安装 VS Code)

5. 自定义 Hexo 命令

你可以在 package.json 里添加自定义脚本,例如:

1
2
3
4
5
6
{
"scripts": {
"dev": "hexo clean && hexo g && hexo s",
"deploy": "hexo clean && hexo g && hexo d"
}
}

然后直接运行:

1
2
npm run dev     # 相当于 hexo clean && hexo g && hexo s
npm run deploy # 相当于 hexo clean && hexo g && hexo d

总结

用途 完整命令 简写
新建文章 hexo new "标题" hexo n "标题"
生成静态文件 hexo generate hexo g
启动服务器 hexo server hexo s
部署 hexo deploy hexo d
清除缓存 hexo clean hexo c
新建草稿 hexo new --draft "标题" hexo n -d "标题"

这些简写可以大幅提升你的 Hexo 使用效率!🚀