Hexo常用指令大全
title: Hexo常用指令大全
date: 2025-03-02 19:33:33
categories: Hexo教程
tags:
- Hexo
toc: true
Hexo 常用命令速查表
命令 | 功能 | 常用参数/示例 |
---|---|---|
初始化 | ||
npm install -g hexo-cli | 全局安装Hexo命令行工具 | |
hexo init <folder> | 初始化博客项目 | hexo init myblog |
npm install | 安装依赖包(在项目目录执行) | |
内容管理 | ||
hexo new "标题" | 新建文章 | hexo new "Hello World" |
hexo new page "名称" | 新建页面 | hexo new page "about" |
hexo publish <filename> | 发布草稿 | hexo publish draft/untitled.md |
生成与预览 | ||
hexo generate | 生成静态文件(简写hexo g ) | hexo g --watch (监听文件变化) |
hexo server | 启动本地服务器(简写hexo s ) | hexo s -p 5000 (指定端口) |
hexo clean | 清除缓存和生成文件 | 常与生成命令组合使用 |
部署 | ||
npm install hexo-deployer-git --save | 安装Git部署插件 | |
hexo deploy | 部署到服务器(简写hexo d ) | hexo d --generate (先生成后部署) |
组合命令 | ||
hexo g -d | 生成后立即部署 | 常用部署组合 |
hexo s -g | 生成后启动服务器 | 开发调试常用 |
高级操作 | ||
hexo list <type> | 列出所有文章/页面等 | hexo list post |
hexo version | 查看Hexo版本 | |
hexo --config custom.yml | 使用自定义配置文件 | 多环境配置时使用 |
典型工作流示例
# 1. 创建新文章
hexo new "深入理解Hexo架构"
# 2. 本地写作并预览
hexo clean && hexo g && hexo s
# 3. 部署到GitHub
hexo clean && hexo g -d
配置注意要点
- 部署配置(
_config.yml
)
deploy:
type: git
repo: https://github.com/用户名/仓库名.git
branch: gh-pages
- 主题配置示例
theme: icarus # 需先安装主题到themes目录
常用插件推荐
插件 | 功能 | 安装命令 |
---|---|---|
hexo-abbrlink | 生成永久链接 | npm install hexo-abbrlink --save |
hexo-all-minifier | 压缩静态资源 | npm install hexo-all-minifier --save |
hexo-generator-search | 添加本地搜索 | npm install hexo-generator-search --save |
掌握这些命令可提升博客管理效率,建议结合--debug
参数排查问题:
hexo g --debug # 显示详细生成日志
icarus教程:https://ppoffice.github.io/hexo-theme-icarus/categories/Widgets/
我的个人博客:https://garybyd.github.io/