部署Hexo框架并应用Butterfly主题

系统:Centos7

安装git

1
yum install -y git

安装node.js和npm工具

一键部署

1
2
yum install -y nodejs
yum install -y npm

Centos7下可能出现的问题

1
2
3
4
5
6
7
8
[root@localhost ~]# yum install -y nodejs
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* extras: mirrors.aliyun.com
* updates: mirrors.huaweicloud.com
没有可用软件包 nodejs。
错误:无须任何处理

手动安装

进入官网,请根据自己的操作系统选择nodejs版本,演示使用Linux Binaries (x64)

1
2
yum install wget -y
wget https://nodejs.org/dist/v16.16.0/node-v16.16.0-linux-x64.tar.xz

解压

1
tar -xvf node-v16.16.0-linux-x64.tar.xz

设置全局变量(使用添加软连接的方式)

1
2
3
ln -s /root/node-v16.16.0-linux-x64/bin/node /usr/local/bin/node

ln -s /root/node-v16.16.0-linux-x64/bin/npm /usr/local/bin/npm

测试

1
2
node -v
npm -v
1
2
3
4
[root@localhost ~]# node -v
v16.15.1
[root@localhost ~]# npm -v
8.11.0

安装Hexo

1
npm install -g hexo-cli

将Hexo命令添加到环境变量中

1
ln -s /root/node-v8.9.4-linux-x64/lib/node_modules/hexo-cli/bin/hexo /usr/local/bin/hexo

使用Hexo

此处非本文重点,请查阅Hexo中文文档

应用Butterfly主题

进入Hexo根目录,即有themes文件夹的目录

1
git clone -b master https://gitee.com/immyw/hexo-theme-butterfly.git themes/butterfly

修改 Hexo 根目录下的 _config.yml,把主题改为butterfly

1
theme: butterfly

修改完毕后,启用网站发现网页显示如下内容


extends includes/layout.pug block content include ./includes/mixins/post-ui.pug #recent-posts.recent-posts +postUI include includes/pagination.pug


请下载安装 pug 以及 stylus 的渲染器

1
npm install hexo-renderer-pug hexo-renderer-stylus --save

安装完毕后重新运行,即可应用Butterfly主题