Hexo静态博客主题与插件推荐

主题推荐:

我的博客使用了《NexT》主题,是一款风格优雅高质量的Hexo主题。

NexT主题

  • 安装
    1
    npm install hexo-theme-next
  • 更新
    1
    npm install hexo-theme-next@latest
  • 复制
    1
    cp node_modules/hexo-theme-next/_config.yml _config.next.yml

    ⚠️注意:

    1. 请将_config.next.yml主题配置文件复制到Hexo根目录,防止主题更新覆盖配置文件;
    2. 主题配置内容只需修改根目录_config.next.yml即可;
    3. 最后_config.yml 配置文件启动NexT
1
2
3
4
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: next

第三方插件推荐:

不再需要重新加载整页,不再需要多个HTTP 请求,提供快速的浏览体验。

安装

1
npm install pjax

修改根目录配置文件_config.next.yml

1
2
# 轻松在您的网站上启用快速Ajax 导航。
pjax: true

为hexo 的每个帖子创建一个且唯一的链接

安装

1
npm install hexo-abbrlink --save

编辑_config.yml添加下列内容:

1
2
3
4
5
6
7
8
9
# URL
## 如果您的网站放在子目录中,请将 url 设置为“http://example.com/child”,并将 root 设置为“/child/”
url: http://www.imlam.com
root: /
permalink: archives/:abbrlink.html
abbrlink:
alg: crc32 # 算法:crc16(default) and crc32
rep: hex # 进制:dec(default) and hex
permalink_defaults:

该插件用于生成搜索索引文件,其中包含文章的所有必要数据,您可以使用这些数据为博客编写本地搜索引擎。

安装

1
npm install hexo-generator-searchdb --save

修改根目录配置文件_config.next.yml

1
2
3
4
5
6
7
8
9
10
11
12
# 本地搜索
local_search:
enable: true
# 如果是auto,则通过更改输入触发搜索。
# If manual, 按回车键或搜索按钮触发搜索。
trigger: auto
# 显示每篇文章的前 n 个结果,设置为 -1 则显示所有结果
top_n_per_article: 3
# 将 html 字符串转义为可读字符串。
unescape: false
# 页面加载时预加载搜索数据。
preload: false

用于让所有图像自动支持延迟加载。借助此功能,它将大大提高加载性能。

安装

1
npm install hexo-lazyload --save

修改根目录配置文件_config.next.yml

1
lazyload: true

自动压缩html、js、css并使其整洁。

安装

1
npm install hexo-neat --save

修改根目录配置文件_config.next.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 压缩js
# hexo-neat
# 博文压缩
neat_enable: true
# 压缩html
neat_html:
enable: true
exclude:
# 压缩css
neat_css:
enable: true
exclude:
- '**/*.min.css'
# 压缩js
neat_js:
enable: true
mangle: true
output:
compress:
exclude:
- '**/*.min.js'
- '**/jquery.fancybox.pack.js'
- '**/index.js'

Hexo 的站点地图生成器。

安装

1
npm install hexo-generator-sitemap --save

修改根目录配置文件_config.next.yml

1
2
3
4
5
6
sitemap:
path: sitemap.xml
# template: ./sitemap_template.xml
rel: false
tags: true
categories: true

自动为 hexo 博客文章中的所有外部链接添加 nofollow 属性。

安装

1
npm install hexo-autonofollow --save

修改根目录配置文件_config.next.yml

1
2
3
4
5
nofollow:
enable: true
exclude:
- exclude1.com
- exclude2.com
  • exclude - 排除域名

  • NexT主题源加载优化

修改根目录配置文件_config.next.yml

1
2
# Uri of fonts host. E.g. //fonts.googleapis.com (Default)
host: //fonts.lug.ustc.edu.cn