🚀 快速开始

欢迎来到Hexo + Butterfly主题快速入门指南!本教程将帮助你快速搭建一个美观的个人博客。

📦 环境准备

Step 1: 安装 Node.js

Node.js 是运行 Hexo 的基础环境。

下载地址: https://nodejs.org/

1
2
3
# 验证安装
node -v
npm -v

推荐版本: Node.js 14.0 或更高版本

Step 2: 安装 Git

Git 用于版本控制和部署。

下载地址: https://git-scm.com/

1
2
# 验证安装
git --version

Step 3: 安装 Hexo

1
2
3
4
5
# 全局安装 Hexo CLI
npm install -g hexo-cli

# 验证安装
hexo -v

🎨 创建博客

1
2
3
4
5
6
7
8
9
# 1. 初始化博客
hexo init my-blog
cd my-blog

# 2. 安装依赖
npm install

# 3. 启动本地服务器
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
2
# 修改主题配置
theme: butterfly

安装依赖插件

1
npm install hexo-renderer-pug hexo-renderer-stylus --save

⚙️ 基础配置

网站信息配置

编辑 _config.yml

1
2
3
4
5
6
7
8
# Site
title: 你的博客名称
subtitle: '副标题'
description: '网站描述'
keywords: 关键词1, 关键词2
author: 你的名字
language: zh-CN
timezone: 'Asia/Shanghai'

URL 配置

1
2
3
# URL
url: http://yoursite.com
permalink: :year/:month/:day/:title/

📝 创建第一篇文章

1
2
3
4
# 创建新文章
hexo new "我的第一篇文章"

# 文章位于 source/_posts/我的第一篇文章.md

文章格式

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

本地预览

1
2
3
hexo server
# 或简写
hexo s

部署到 GitHub Pages

  1. 安装部署插件:
1
npm install hexo-deployer-git --save
  1. 配置 _config.yml
1
2
3
4
deploy:
type: git
repo: https://github.com/yourusername/yourusername.github.io.git
branch: main
  1. 部署:
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 生成并部署

📚 下一步


💬 需要帮助?