运行目录为C:\Users\surface\Documents\hexo-blog

安装hexo

npm install -g hexo

新建hexo网站

hexo init

安装依赖

npm install cheerio@0.22.0 --save

下载主题butterfly

git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/Butterfly

修改站点配置文件./_config.yml, 主题修改为Butterfly

theme: Butterfly

安装依赖

npm install hexo-renderer-pug hexo-renderer-stylus --save or yarn add hexo-renderer-pug hexo-renderer-stylus

把主题配置文件./_config.yml复制到./source/_data/_config.butterfly.yml

添加ICP备案号
修改文件目录./themes/butterfly/layout/includes/footer.pug
打开并添加如下内容

    //- 注释hexo和butterfly的内容
    //- .framework-info
    //-   span= _p('footer.framework') + ' '
    //-   a(href='https://hexo.io')= 'Hexo'
    //-   span.footer-separator |
    //-   span= _p('footer.theme') + ' '
    //-   a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'


    //- 增加备案号内容
    .framework-info
      img(src = 'https://www.beian.gov.cn/img/new/gongan.png')
      span= ' '
      a(href='https://beian.miit.gov.cn/')= '湘ICP备2020021092号-1'

如图所示

使用hexo-abbrlink生成永久短链接

在博客根目录下,使用如下命令安装插件:

npm install hexo-abbrlink --save

安装好后,修改博客根目录下的 _config.yml 配置文件:

permalink: :year:month:day:abbrlink/   # 具体配置参考Hexo文档https://hexo.io/zh-cn/docs/permalinks

注意:末尾必须要有 / ,否则点击某博文的时候将进行下载操作而不是跳转到该博文!

另外还需要添加如下的对该插件的配置项:

# abbrlink config
abbrlink:
alg: crc16 #support crc16(default) and crc32
rep: dec #support dec(default) and hex
drafts: false #(true)Process draft,(false)Do not process draft
# Generate categories from directory-tree
# depth: the max_depth of directory-tree you want to generate, should > 0
auto_category:
enable: false
depth:

注意:清理缓存文件后重建hexo clean,方能生效

部署cos上传插件

安装插件

npm install hexo-deployer-cos --save

接下面我们配置hexo的配置文件,首先打开根目录的_config.yml配置文件,将原来的deploy替换为下面的内容:

```deploy:   
type: cos
appId: yourAPPID
secretId: yourSecretId
secretKey: yourSecretKey
bucket: yourBucketName-yourAPPID
region: yourRegion

假如说我的APPID1251234567secretIdABCDEFGHIGKLMNOPQRSTUVWXYZsecretKeyabcdefghijklmnopqrstuvwxyz,创建的bucketwwwregion可用地区是成都,也就是ap-chengdu

那么我的_config.ymldeploy配置为:

deploy:   
type: cos
appId: 1251234567
secretId: ABCDEFGHIGKLMNOPQRSTUVWXYZ
secretKey: abcdefghijklmnopqrstuvwxyz
bucket: www-1251234567
region: ap-chengdu