前言

本博客搭建参考于大佬hexo-theme-Fomalhaut:的开源项目,此文档主要用来自己熟悉hexo搭建和一些基本用法。

目录

  1. hexo 博客搭建
  2. hexo 博客配置 ⇦您当前在此位置🪂
  3. hexo+butterfly 博客主题
  4. hexo+butterfly 主题魔改
  5. hexo 基础语法和外挂标签
  6. hexo 生成文章统计图
  7. hexo 添加百度统计
  8. hexo 使用git将Hexo博客部署到服务器

生成永久固定链接

Hexo默认的静态URL格式是 :year/:month/:day/:title,也就是按照年、月、日、标题来生成固定链接的。如http://xxx.yy.com/2020/07/06/hello-world

这种默认配置的缺点就是一般文件名是中文,导致url链接里有中文出现,这会造成很多问题,也不利于seo,另外就是年月日都会有分隔符。

  1. 安装插件
1
npm install hexo-abbrlink --save
  1. 修改_config.yml文件中的配置项(记得把原来的permalink:删除掉):
1
2
3
4
5
#设置永久链接
permalink: :abbrlink.html # 此处可以自己设置,也可以直接使用 :/abbrlink
abbrlink:
alg: crc16 #算法: crc16(default) and crc32
rep: dec #进制: dec(default) and hex

文件夹安装年/月/日归类

1
new_post_name: :year/:month/:day:title.md # File name of new posts

基础用法说明

Front-matter

Front-matter 是 markdown 文件最上方以---分隔的区域,用于指定个别档案的变数。

  • Page Front-matter 用于页面配置
  • Post Front-matter 用于文章页配置

Page Front-matter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---  
title:
date:
updated:
type:
comments:
description:
keywords:
top_img:
mathjax:
katex:
aside:
aplayer:
highlight_shrink:
---
写法 解释
title 【必需】页面标题
date 【必需】页面创建日期
type 【必需】标籤、分类和友情链接三个页面需要配置
updated 【可选】页面更新日期
description 【可选】页面描述
keywords 【可选】页面关键字
comments 【可选】显示页面评论模块(默认 true)
top_img 【可选】页面顶部图片
mathjax 【可选】显示mathjax(当设置mathjax的per_page: false时,才需要配置,默认 false)
kates 【可选】显示katex(当设置katex的per_page: false时,才需要配置,默认 false)
aside 【可选】显示侧边栏 (默认 true)
aplayer 【可选】在需要的页面加载aplayer的js和css,请参考文章下面的音乐 配置
highlight_shrink 【可选】配置代码框是否展开(true/false)(默认为设置中highlight_shrink的配置)

Post Front-matter

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:
cover:
toc:
toc_number:
toc_style_simple:
copyright:
copyright_author:
copyright_author_href:
copyright_url:
copyright_info:
mathjax:
katex:
aplayer:
highlight_shrink:
aside:
---
写法 解释
title 【必需】文章标题
date 【必需】文章创建日期
updated 【可选】文章更新日期
tags 【可选】文章标籤
categories 【可选】文章分类
keywords 【可选】文章关键字
description 【可选】文章描述
top_img 【可选】文章顶部图片
cover 【可选】文章缩略图(如果没有设置top_img,文章页顶部将显示缩略图,可设为false/图片地址/留空)
comments 【可选】显示文章评论模块(默认 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)

标签页

  • 前往你的Hexo博客根目录,打开Git Bash执行如下命令:
1
hexo new page tags


修改index.md,添加type: “tags”`。

1
2
3
4
5
---
title: tags
date: 2024-04-13 18:25:31
type: "tags"
---

未完…