下载主题

使用npm方式安装

1
npm i hexo-theme-butterfly

安装好后可以在博客文件夹根目录的node_modules下找到hexo-theme-butterfly文件夹,这就是我们butterfly的主题啦

主题应用

①在配置文件中使用bufttery主题
修改_config.yml文件中的theme选项

②安装butterfly需要的渲染器

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

③新建一个butterfly主题配置文件(不是必须)

将原有的配置文件复制一份并重命名为_config.butterfly.yml
后续我们的直接改这个配置就可以了

④接着我们启动项目

1
2
3
4
5
6
7
8
##先清理
hexo clean

##再构建
hexo g

##启动
hexo s

然后我们访问本地端口就可以看到主题已经修改好啦

主题使用

1.新建文章

我们可以删除原来的HelloWorld文章
在博客根目录/source/_posts文件夹下我们可以删除、新建文章
新建文章只需要新建一个.md文件即可,推荐使用typora写文章

2.添加文章头

hexo博客是需要一个头信息来表示文章信息的

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
---
title: 文章标题
date: 创建日期
updated: 修改日期
tags: 标签
categories: 分类
keywords: 关键字
description: 描述
top_img: 文章顶部图片
comments: 文章缩略图(如果没有设置top_img,文章页顶部将显示缩略图,可设为false/图片地址/留空)
cover: 显示文章评论模块(默认 true)
toc: 显示文章TOC(默认为设置中toc的enable配置)
toc_number: 显示toc_number(默认为设置中toc的number配置)
toc_style_simple: 显示 toc 简洁模式
copyright: 显示文章版权模块(默认为设置中post_copyright的enable配置)
copyright_author: 文章版权模块的文章作者
copyright_author_href: 文章版权模块的文章作者链接
copyright_url: 文章版权模块的文章连结链接
copyright_info: 文章版权模块的版权声明文字
mathjax: 显示mathjax(当设置mathjax的per_page: false时,才需要配置,默认 false)
katex: 显示katex(当设置katex的per_page: false时,才需要配置,默认 false)
aplayer: 在需要的页面加载aplayer的js和css,请参考文章下面的音乐 配置
highlight_shrink: 配置代码框是否展开(true/false)(默认为设置中highlight_shrink的配置)
aside: 显示侧边栏 (默认 true)
---

一般只需要用到title、date、updated、tags、categories

3.添加标签页

①在博客根目录执行命令

1
hexo new page tags

②执行完命令后会在/source/tags下生成index.md文件
③修改index.md,添加type: "tags"

1
2
3
title: tags
date: 2022-12-30 11:07:03
type: "tags"

4.添加友情链接

①在博客根目录下执行命令:

1
hexo new page link

②执行完命令后会在/source/link下生成index.md文件
③修改这个index.md文件,添加type: "link"

1
2
3
4
5
---
title: link
date: 2022-12-30 11:16:08
type: "link"
---

④在/source/_data下创建一个link.yml文件(如果没有_data文件夹,自己创建,并写入以下信息)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- class_name: 1.技术支持
class_desc: 本网站的搭建由以下开源作者提供技术支持
link_list:
- name: Hexo
link: https://hexo.io/zh-cn/
avatar: https://d33wubrfki0l68.cloudfront.net/6657ba50e702d84afb32fe846bed54fba1a77add/827ae/logo.svg
descr: 快速、简单且强大的网志框架
siteshot: https://source.fomal.cc/siteshot/hexo.io.jpg

- class_name: 2.友情链接
class_desc: 一些好朋友~~
link_list:
- name: Fomalhaut🥝
link: https://fomal.cc/
avatar: /assets/head.jpg
descr: Future is now 🍭🍭🍭
siteshot: https://source.fomal.cc/siteshot/www.fomal.cn.jpg

5.插入图片

①配置文件修改
_config.yml中的:post_asset_folder改为true
②安装插件
npm install https://github.com/CodeFalling/hexo-asset-image -- save
③生成文章
使用命令生成文章:hexo new postName
生成好后会在/source/_posts文件夹下生成一个.md的文章和一个同名的文件夹用来存放图片
④添加文章的时候直接写文件夹/图片名就可以,例如![](test/1.png)

⑤typora设置

在文件->偏好设置中,设置复制到指定路径

我们在typora复制图片时就会直接放到hexo生成的图片文件夹下啦