我的博客:https://monologuue.github.io/

搭建hexo看的视频:https://www.bilibili.com/video/BV1Ju4m1c7WR/?spm_id_from=333.337.search-card.all.click&vd_source=802632f153a1ecb77319c61fa70dccdf

美化主题看的视频:https://www.bilibili.com/video/BV1JP411P7gc/?spm_id_from=333.337.search-card.all.click&vd_source=802632f153a1ecb77319c61fa70dccdf


一、搭建hexo

**下载好 nodejs 和 git **

在github上搭建仓库

生成SSH Keys

在Git bash here上输入

1
ssh-keygen -t rsa -C "邮件地址"

回车,然后找到id_rsa.pub文件,复制其中内容到github账号的SSH keys上

在Git bash here上输入

1
ssh -T [email protected]

回车,然后输入yes,回车。

下载hexo

在Git bash here上依次输入

1
2
3
4
5
npm install hexo-cli -g
hexo init
hexo install
hexo g
hexo s

然后ctrl+c关闭本地服务器

上线博客

打开_config.yml文件,拖到最底下,把deploy下面的内容改成这样

1
2
3
4
deploy:
type: git
repository: [email protected]:Monologuue/Monologuue.github.io.git
branch: main

repository后面的内容为github上的仓库页面的code

部署博客

在博客文件夹中打开Git bash here,依次输入

1
2
3
npm install hexo-deployer-git --save
hexo g
hexo d

这样就搭建好了毛坯房,博客页面是默认的hexo


二、美化主题

安装butterfly主题和需要用到的渲染器

在博客文件下打开Git bash here,依次输入

1
2
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
npm install hexo-renderer-pug hexo-renderer-stylus --save

修改_config.yml文件,拖到最下面,找到theme,把后面内容改成butterfly,记得保存

然后把themes文件夹中的 _config.yml 重命名为 _config.butterfly.yml,复制到博客的根目录下与_config.yml同级,像这样

然后就是跟着视频教程,我也写不出来,东西太多了,修改主题不难,就是很麻烦,如果看得懂英文就没什么太大的问题

主题配置文件(最好用vscode打开) _config.butterfly.yml

这其中有许多供人选择的模块,有想要的就在enable: 后加上true,相反就加false,例如

我选择鼠标点击效果是出现爱心

想要添加图片就在对应位置添加图片的路径

像这些如果有需要的功能可以把注释的 # 去掉

应用主题

在博客文件下打开Git bash here,依次输入

1
2
3
hexo cl
hexo g
hexo d

如果博客页面没有变换,就多等几分钟,延迟挺大的