hexo redefine主题更换全局字体

LinJiefeng Lv3

📥下载网页用字体(霞鹜文楷)

  1. 在主题文件夹目录使用npm下载字体
1
npm install lxgw-wenkai-screen-webfont --save

📁源码文件夹需要新增的文件夹及文件

  1. 新增文件夹及文件
  • /source/css/custom.css
1
2
3
4
5
6
7
8
9
10
/* 副标题一言:字体覆盖 */
#subtitle,
#subtitle * {
font-family: "LXGW WenKai Screen", "LXGW WenKai Screen R", sans-serif !important;
}

/* 打字机光标(可选,让光标与文字风格一致) */
.typed-cursor {
font-family: "LXGW WenKai Screen", sans-serif !important;
}
  • 把/node_modules/lxgw-wenkai-screen-webfont复制到/source/fonts 下

目录结构

1
2
3
4
5
6
7
8
9
10
hexo-blog/
└── source/
└── css/
└── custom.css
└── fonts/
└── lxgw-wenkai-screen-webfont/
├── lxgwwenkaigbscreen.css
├── CHANGELOG.md
├── files
└── ...

⚙️修改配置文件

打开_config.redefine.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
55
56
57
58
59
home_banner:
custom_font:
enable: true
family: "LXGW WenKai Screen"
url: /fonts/lxgw-wenkai-screen-webfont/lxgwwenkaigbscreen.css

global:
fonts:
chinese:
enable: true
family: "LXGW WenKai Screen"
url: "/fonts/lxgw-wenkai-screen-webfont/lxgwwenkaigbscreen.css"
english:
enable: true
family: "LXGW WenKai Screen"
url: "/fonts/lxgw-wenkai-screen-webfont/lxgwwenkaigbscreen.css"
title:
enable: true
family: "LXGW WenKai Screen"
url: "/fonts/lxgw-wenkai-screen-webfont/lxgwwenkaigbscreen.css"

inject:
enable: true
head:
- '<link rel="stylesheet" href="/fonts/lxgw-wenkai-screen-webfont/lxgwwenkaigbscreen.css">'
- '<link rel="stylesheet" href="/css/custom.css">'
- |
<style>
/* ① 全局兜底(保留原有部分) */
body,
main, article,
.post-content, .markdown-body,
.shuoshuo-item, .friend-links {
font-family: "LXGW WenKai Screen", "LXGW WenKai", sans-serif !important;
}

/* ② 导航栏(Redefine 的导航栏容器,含左上角 Logo 与右侧菜单) */
.navbar-container,
.navbar-content,
.navbar-content .left,
.navbar-content .right,
.logo-title,
.logo-title h1,
.navbar-list,
.navbar-list .navbar-item,
.navbar-list .navbar-item a,
.navbar-list .navbar-item a.active {
font-family: "LXGW WenKai Screen", "LXGW WenKai", sans-serif !important;
}

/* ④ 通用标题兜底,防止漏网 */
h1, h2, h3, h4, h5, h6 {
font-family: "LXGW WenKai Screen", "LXGW WenKai", sans-serif !important;
}
/* 将下面的选择器替换为你实际找到的副标题选择器 */
.banner-text .h2 > #subtitle {
font-family: "LXGW WenKai Screen", sans-serif !important;
}
</style>

🔄更新

1
2
hexo cl # 清空
hexo g # 编译
  • 标题: hexo redefine主题更换全局字体
  • 作者: LinJiefeng
  • 创建于 : 2026-11-18 16:20:51
  • 更新于 : 2026-11-18 16:23:31
  • 链接: https://blog.icsteam.cn/2026/11/18/117_changRedefineFonts/
  • 版权声明: 本文章采用 CC BY 4.0 进行许可。
评论