NexT主题自定义设置

Hexo NexT 主题的自定义

关于 NexT 主题版本

GitHub 上目前有 3 个仓库,本博客采用最新版。

参考:Upgrade | NexT

NexT 配置文件

最新版的 NexT 建议将主题配置文件复制到博客根目录下,并命名为_config.next.yml,然后修改此文件来实现对主题的自定义。

1
2
3
4
# Installed through npm
cp node_modules/hexo-theme-next/_config.yml _config.next.yml
# Installed through Git
cp theme/next/_config.yml _config.next.yml

参考:Configuration | NexT

代码块配色

v8 版本支持对亮色模式和暗色模式下的代码块分别设置不同的配色,所有可用的配色方案可在https://theme-next.js.org/highlight/预览并选择。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
codeblock:
# Code Highlight theme
# All available themes: https://theme-next.js.org/highlight/
theme:
light: atom-one-light
dark: atom-one-dark
prism:
light: prism
dark: prism-dark
# Add copy button on codeblock
copy_button:
enable: true
# Available values: default | flat | mac
style: mac

字体修改

在主题配置文件中,关于字体设置的选项如下

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
# ---------------------------------------------------------------
# Font Settings
# ---------------------------------------------------------------
# Find fonts on Google Fonts (https://fonts.google.com)
# All fonts set here will have the following styles:
# light | light italic | normal | normal italic | bold | bold italic
# Be aware that setting too much fonts will cause site running slowly
# ---------------------------------------------------------------
# Web Safe fonts are recommended for `global` (and `title`):
# Arial | Tahoma | Helvetica | Times New Roman | Courier New | Verdana | Georgia | Palatino | Garamond | Comic Sans MS | Trebuchet MS
# ---------------------------------------------------------------

font:
enable: true

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

# 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: true
family: Noto Serif SC
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: true
family:

首先启用字体功能

1
2
3
4
font:
enable: true
# Uri of fonts host, e.g. https://fonts.googleapis.com (Default).
host: fonts.loli.net

默认情况下,从fonts.googleapis.com加载字体,由于众所周知的原因,可将host修改为fonts.loli.net

https://fonts.google.com上查看喜欢的字体,例如将博客全局字体修改为Noto Serif SC

1
2
3
4
5
# Global font settings used for all elements inside <body>.
global:
external: true
family: Noto Serif SC
size:

以上,就能实现最基本的字体修改。

更多修改参见:
NexT 主题 v8 配置自定义字体
Hexo Next 主题字体相关配置