🚀 快速开始
欢迎来到Hexo + Butterfly主题快速入门指南!本教程将帮助你快速搭建一个美观的个人博客。
📦 环境准备
Step 3: 安装 Hexo
1 2 3 4 5
| npm install -g hexo-cli
hexo -v
|
🎨 创建博客
1 2 3 4 5 6 7 8 9
| hexo init my-blog cd my-blog
npm install
hexo server
|
访问 http://localhost:4000 查看你的博客!
🦋 安装 Butterfly 主题
方法一:Git 克隆(推荐)
1 2
| cd my-blog git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly
|
方法二:npm 安装
1
| npm install hexo-theme-butterfly
|
配置主题
编辑根目录的 _config.yml:
安装依赖插件
1
| npm install hexo-renderer-pug hexo-renderer-stylus --save
|
⚙️ 基础配置
网站信息配置
编辑 _config.yml:
1 2 3 4 5 6 7 8
| title: 你的博客名称 subtitle: '副标题' description: '网站描述' keywords: 关键词1, 关键词2 author: 你的名字 language: zh-CN timezone: 'Asia/Shanghai'
|
URL 配置
1 2 3
| url: http://yoursite.com permalink: :year/:month/:day/:title/
|
📝 创建第一篇文章
文章格式
1 2 3 4 5 6 7 8 9 10 11 12
| --- title: 我的第一篇文章 date: 2025-01-08 10:00:00 tags: - 标签1 - 标签2 categories: - 分类名称 cover: /img/cover.jpg ---
这里是文章内容...
|
🚀 生成和部署
生成静态文件
1 2 3 4 5 6 7
| hexo clean
hexo generate
hexo g
|
本地预览
部署到 GitHub Pages
- 安装部署插件:
1
| npm install hexo-deployer-git --save
|
- 配置
_config.yml:
1 2 3 4
| deploy: type: git repo: https://github.com/yourusername/yourusername.github.io.git branch: main
|
- 部署:
1 2 3 4 5 6
| hexo deploy
hexo d
hexo g -d
|
🎯 常用命令
| 命令 |
说明 |
hexo init |
初始化博客 |
hexo new "title" |
创建新文章 |
hexo generate |
生成静态文件 |
hexo server |
启动本地服务器 |
hexo deploy |
部署网站 |
hexo clean |
清理缓存 |
hexo g -d |
生成并部署 |
📚 下一步