我的第一篇 Butterfly 博客
1. 环境准备
在开始之前,需要先准备好环境:
安装完成后,检查版本:
1 | node -v |
然后启动本地服务:
1 | hexo s |
浏览器访问 http://localhost:4000,就能看到默认页面。
3. 更换 Butterfly 主题
进入博客目录 myblog,下载 Butterfly 主题:
1 | git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly |
修改 _config.yml 文件,把主题改成:
1 | theme: butterfly |
安装必要依赖:
1 | npm install hexo-renderer-pug hexo-renderer-stylus --save |
重启服务后,你就能看到漂亮的 Butterfly 界面啦。
4. 写文章
使用命令新建文章:
1 | hexo new post "我的第一篇文章" |
文章会生成在 source/_posts/ 目录下,你可以用 Markdown 来写内容。
5. 部署到 GitHub Pages
- 在 GitHub 创建一个仓库,命名为:
你的用户名.github.io - 安装部署插件:
1 | npm install hexo-deployer-git --save |
- 编辑
_config.yml,加入部署配置:
1 | deploy: |
- 执行命令部署:
1 | hexo clean |
部署完成后,访问 https://你的用户名.github.io 就能看到你的博客啦!
6. 常用命令
hexo new post "文章标题":新建文章hexo s:启动本地服务器hexo g:生成静态文件hexo d:部署到远程
总结
从零开始搭建博客其实并不难,主要流程就是:
👉 安装 Hexo → 使用 Butterfly 主题 → 写文章 → 部署上线
之后你还可以:
- 美化主题(添加背景、切换字体、增加特效)
- 配置评论系统(Waline、Gitalk、Twikoo 等)
- 添加站点统计(不蒜子、百度统计、Google Analytics)
未来再继续折腾!🚀
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 TeachCraft Blog!
