Centos7.6搭建hexo+butterfly
Centos7.6搭建hexo+butterfly
1. 配置Node.js
1. node.js的安装
1 | wget https://nodejs.org/dist/v14.17.4/node-v14.17.4-linux-x64.tar.xz |
2. git的安装
1 | yum -y install git |
3. 安装cnpm
1 | npm install -g cnpm --registry=https://registry.npm.taobao.org |
2. 安装hexo并初始化博客
1 | #安装hexo |
3. 更换 butterfly 主题
1. 稳定分支
1 | git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
2. 开发分支
1 | git clone -b dev https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
3. 或者用 NPM
在Hexo目录下
1 | npm i hexo-theme-butterfly |
4. 启用主题
在Hexo目录下,编辑_config.yml
1 | theme: butterfly |
启动hexo
1. 安装screen
1 | yum -y install screen |
2. screen常用命令
1 | screen -ls # 查看所有会话 |
3.使用screen启动hexo
1 | screen -S hexo |
遇到的问题
1. 主题相关
复制粘贴另外一台vps上的butterfly的_config.yml文件之后报错:
1 | extends includes/layout.pug block content include includes/recent-posts.pug include includes/partial |
解决方案:
执行如下命令:
1 | npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive |
清除缓存
hexo clean
生成静态文件
hexo g
然后重新复制粘贴即可
2. 修改hexo默认端口
hexo端口的默认配置文件在:
node_modules\hexo-server\index.js
把4000
改成80
就好了
3. hexo写作
Hexo 有三种默认布局:post
、page
和 draft
,它们分别对应不同的路径,而自定义的其他布局和 post
相同,都将储存到 source/_posts
文件夹。
布局路径postsource/_postspagesourcedraftsource/_drafts
如果你不想你的文章被处理,你可以将 Front-Matter 中的
layout:
设为false
.
默认会以 post
创建新文件
创建新文章的命令是:
1 | hexo new "wenzhang" |
也可以编辑 /root/blog/scaffolds/post.md
添加
1 | --- |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Re:从零开始的安全之旅!