文章目录
  1. 1. 安装HEXO
  2. 2. 初始化
  3. 3. 生成静态页面
  4. 4. 启动本地服务,进行文章预览调试
  5. 5. 配置Github
  6. 6. deploy配置
  7. 7. 部署步骤
  8. 8. 其他
  9. 9. 主题

安装HEXO

1
npm install -g hexo

初始化

1
2
hexo init // 当前文件夹初始化
hexo init xxx // 当前目录下创建xxx目录初始化

生成静态页面

1
hexo generate 或 hexo g

启动本地服务,进行文章预览调试

1
hexo server 或 hexo s

配置Github

分为两种类型

  1. 个人主页: 建立与你用户名对应的仓库,仓库名必须为your_user_name.github.io,默认处理master分支。直接通过your_user_name.github.io域名访问
  2. 项目主页: 其他仓库名,默认处理gh-pages分支,通过your_user_name.github.io/项目名 访问,

deploy配置

  • 安装hexo-deployer-git
    1
    npm install hexo-deployer-git --save

修改hexo工程配置文件_config.yml的deploy:

1
2
3
4
5
6
7
8
9
deploy:
type: git // 必填
repo: <repository url> // 必填
branch: [branch] // 必填
message: [message]
name: [git user] // 必填
email: [git email]
extend_dirs: [extend directory]
ignore_hidden: false # default is true

部署步骤

每次部署的步骤,可按以下三步来进行。

1
2
3
hexo clean
hexo generate
hexo deploy

其他

1
2
3
4
5
6
7
hexo new "postName" #新建文章
hexo new page "pageName" #新建页面
hexo generate #生成静态页面至public目录
hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
hexo deploy #将.deploy目录部署到GitHub
hexo help #查看帮助
hexo version #查看Hexo的版本

主题

https://hexo.io/themes/可以选择不同主题使用,推荐以下几款:

1
[jacman](https://github.com/wuchong/jacman)

文章目录
  1. 1. 安装HEXO
  2. 2. 初始化
  3. 3. 生成静态页面
  4. 4. 启动本地服务,进行文章预览调试
  5. 5. 配置Github
  6. 6. deploy配置
  7. 7. 部署步骤
  8. 8. 其他
  9. 9. 主题