使用hexo搭建博客经验分享
我想,每个程序员都希望有一个专属于自己的博客网站,用来分享知识,记录成长,督促形成产出。
搭建博客的方式我已知的有以下几种:
- 自己从头到尾手撸一个博客网站,这里安利我们的姜同学写博客的小姜
- 使用WordPress搭建
- 使用hexo搭建
在分别尝试使用WordPress和hexo搭建博客网站之后,基于hexo简单易搭建,轻量的特点,最终基于hexo搭建了属于自己的博客。
相关资料可在hexo官网地址 中获得
快速搭建
我的博客搭建在阿里云云服务器中,没有自己的服务器的小伙伴可参考搭建git托管的hexo博客
安装基础环境
安装nodejs
由于hexo基础环境需要Node.js和Git,需要先安装Node.js
1 | yum -y install nodejs #安装npm |
验证nodejs环境是否安装正常
1 | node -v #显示nodejs版本号 |
出现版本nodejs版本号即成功
安装hexo
1 | npm install -g hexo-cli #安装hexo-cli |
hexo butterfly主题
hexo默认主题不够美观,butterfly主题简约大气
butterfly主题官网
安装butterfly主题
安装核心组件
1 | npm install hexo-renderer-pug hexo-renderer-stylus --save |
安装butterfly主题
1 | npm i hexo-theme-butterfly |
配置hexo和butterfly主题
butterfly主题相关配置可见官方配置文档
官方配置页面直达
以下为我的配置,可参考
_config.yml配置文件
1 | # Site |
_config.butterfly.yml配置文件(改动部分)
1 | # Site |
几个要点
- _config.yml中主题theme得设置为butterfly才会使butterfly主题生效
- _config.yml中的url地址用于分享文章链接等拼接使用,将其改为对应的nginx配置
- 这两个文件中有我自己的配置部分,需要将其改为你自己的文件地址和配置。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 何知令の博客!