安装Hexo

1.安装Node.js v17.x:

1
2
3
4
5
6
7
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs

# Using Debian, as root
curl -fsSL https://deb.nodesource.com/setup_17.x | bash -
apt-get install -y nodejs

2.安装Hexo

1
2
3
4
5
npm install hexo-cli -g
hexo init blog
cd blog
npm install
hexo server

安装配置Butterfly

1.在hexo根目录下克隆项目

1
git clone -b master https://github.com/jerryc127/hexo-theme-butterfly.git themes/butterfly

2.应用主题

修改Hexo根目录下的_config.yml,把主题改为butterfly

1
theme: butterfly

3.安装插件

1
2
# 安装pug、stylus及本地搜索引擎插件
npm install hexo-renderer-pug hexo-renderer-stylus hexo-generator-searchdb hexo-deployer-git --save

4.升级建议

hexo的根目录创建一个文件_config.butterfly.yml,並把主题目录的_config.yml內容复制到_config.butterfly.yml去。

1
2
# 在hexo的更目录下复制文件
cp themes/butterfly/_config.yml _config.butterfly.yml

Hexo会自动合并主题中的_config.yml_config.butterfly.yml里的配置,如果存在同名配置,会使用_config.butterfly.yml的配置,其优先度交高。

5.配置butterfly

修改_config.butterfly.yml里面的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 开启菜单栏相关选项
menu:
Home: / || fas fa-home
Archives: /archives/ || fas fa-archive
Tags: /tags/ || fas fa-tags
Categories: /categories/ || fas fa-folder-open
# List||fas fa-list:
# Music: /music/ || fas fa-music
# Movie: /movies/ || fas fa-video
# Link: /link/ || fas fa-link
About: /about/ || fas fa-heart

# 开启本地搜索
local_search:
enable: true

# Favicon(網站圖標)
favicon: /img/favicon.png

# Avatar (頭像)
avatar:
img: https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png
effect: false

# Disable all banner image
disable_top_img: false

# The banner image of home page
index_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/index.jpg

# If the banner of page not setting, it will show the top_img
default_top_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/index.jpg

# The banner image of archive page
archive_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/index.jpg

# If the banner of tag page not setting, it will show the top_img
# note: tag page, not tags page (子標籤頁面的 top_img)
tag_img:

# The banner image of tag page
# format:
# - tag name: xxxxx
tag_per_img:

# If the banner of category page not setting, it will show the top_img
# note: category page, not categories page (子分類頁面的 top_img)
category_img: https://cdn.jsdelivr.net/gh/jerryc127/butterfly_cdn@2.1.0/top_img/index.jpg

# The banner image of category page
# format:
# - category name: xxxxx
category_per_img:

部署Hexo到git

1.在github上创建一个项目

img1.png

2.配置hexo主配置文件_config.yml

1
2
3
4
5
# 在配置文件最后段找到deploy配置段,修改如下
deploy:
type: 'git'
repo: git@github.com:Masuri-Y/Masuri-Y.github.io.git
branch: master

3.配置git信息

1
2
3
4
5
6
7
8
# 设置Git的user name和email
git config --global user.email "438214186@qq.com"
git config --global user.name "Masuri-Y"

# 生成密钥
ssh-keygen -t rsa -C "438214186@qq.com"

# 将公钥添加到github

4.将Hexo部署到github

1
2
3
# 在hexo根目录下执行以下命令
hexo g
hexo d

部署完毕后就可以访问地址为:https:\\Masuri-Y.github.io