NexT 主题添加霞鹜文楷字体

最近发现了一款好看的开源字体:霞鹜文楷字体 https://github.com/lxgw/LxgwWenKai,于是打算用到我的 Hexo-NexT 博客主题里面,这里记录一下修改过程。

效果图如下:

霞鹜文楷字体

新建 source/_data/head.njk

添加内容:

1
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.7.0/style.css" />

目前最新版本为 1.7.0,可以点开网址 https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.7.0/ 查询下最新版本。

修改_config.next.yml

修改内容 1:

1
2
custom_file_path:
head: source/_data/head.njk

修改内容 2:

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
# ---------------------------------------------------------------
# Font Settings
# ---------------------------------------------------------------

font:
enable: true

# Uri of fonts host, e.g. https://fonts.googleapis.com (Default).
host: https://fonts.googleapis.com

# Font options:
# `external: true` will load this font family from `host` above.
# `family: Times New Roman`. Without any quotes.
# `size: x.x`. Use `em` as unit. Default: 1 (16px)

# Global font settings used for all elements inside <body>.
global:
external: false
family: "LXGW WenKai"
size:

# Font settings for site title (.site-title).
title:
external: true
family:
size:

# Font settings for headlines (<h1> to <h6>).
headings:
external: true
family:
size:

# Font settings for posts (.post-body).
posts:
external: true
family:

# Font settings for <code> and code blocks.
codes:
external: false
family: "LXGW WenKai Mono, Source Code Pro"