简介

hexo是一个开源的博客系统,对md有很好的支持,在本地安装后,可以推送到git上开启page即可使用github的服务器资源

新设备搭建

  • 克隆git项目

  • 环境依赖

    1
    2
    3
    4
    5
    6
    nodejs
    npm install -g hexo-cli
    npm install hexo-deployer-git --save
    npm install --save hexo-admin
    # 字数统计
    npm install hexo-wordcount --save

首次搭建

安装

依赖nodejs,这里不赘述nodejs安装方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 安装hexo依赖
npm install -g hexo-cli

# 创建文件夹初始化一个hexo项目
mkdir blog
hexo init

# 看下生成了一下目录文件
ls
_config.landscape.yml node_modules scaffolds themes
_config.yml package.json source yarn.lock

# 静态部署和启动服务
hexo g
hexo s

git部署

  • 在git上创建一个项目fireflyso/fireflyso.github.io

  • 修改本地配置文件_config.yml

    1
    2
    3
    4
    deploy:
    type: git
    repository: git@github.com:fireflyso/fireflyso.github.io.git #你的仓库地址
    branch: master
  • 安装部署插件:npm install hexo-deployer-git --save

  • 部署

    1
    2
    3
    hexo clean   #清除缓存文件 db.json 和已生成的静态文件 public
    hexo g #生成网站静态文件到默认设置的 public 文件夹(hexo generate 的缩写)
    hexo d #自动生成网站静态文件,并部署到设定的仓库(hexo deploy 的缩写)

定制化

  • 安装主题,官方教程
    # 使用gitee安装,github网络不稳定
    git clone -b master https://gitee.com/immyw/hexo-theme-butterfly.git themes/butterfly

      # 修改hexo根目录_config.yml文件
      theme: butterfly
    
      # 安装渲染器(非必要)
      npm install hexo-renderer-pug hexo-renderer-stylus --save
    
  • 安装admin插件
    npm install –save hexo-admin