Hexo博客优化记录

今天更换了一个新域名,顺便修改了配置及fluid主题配置、网页访问统计、URL链接优化。

1.域名更换

解析记录

2.MAC风格代码高亮

  • style修改为Night Owl暗色风格;

    image.png
    image.png
  • 接着在路径myblog/themes/fluid/source/css下新建文件mac.styl

  • 在路径myblog/_config.fluid.yml中找到custom_css选项,改为/css/mac.css,原先是相对路径下的iconfont.css

  • 行内代码颜色,从inherit改为#E05B35,打开路径myblog/themes/fluid/source/css/_pages/_base下的base.styl文件,找到code配置项。

3.全局字体配置

  • fluid主题配置文件下,调整代码字体大小及显示比例。
    _config.fluid.yml

4.修改post.md的默认布局

5.网页访问次数统计

6.url链接优化

找了一下有两种办法,一种是npm install hexo-abbrlink --save安装插件,生成一串永久数字id,适合于到时候搜索引擎收录时用。另一种我简单改一下__config.yml下的永久链接格式。

7.压缩静态资源

博客中有大量 HTML、CSS、JS 文件,这些文件为了阅读方便会加入许多回车和空行,但在页面解析时其实会浪费部分时间,此外如果有许多插图,也会拖慢网页加载,并占据 GitHub 仓库的存储空间。

1
2
$ npm install hexo-all-minifier --save  # 出现 npm ERR! code ELIFECYCLE 错误
$ npm install hexo-neat --save # 换成这个后成功安装

之后在配置文件myblog/_config.yml中增加如下内容就行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# hexo-neat
## Docs: https://github.com/rozbo/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博客优化记录
http://paopaotangzu.xyz/cn/hexo_new_configeration/
作者
paopaotangzu
发布于
2025年1月25日
许可协议