0%

Hexo-Next – Change Fonts & Enable Code Copy


The Next theme version used here is 7.8.0.

First, locate the file:

1
/themes/next/_config.yml

Search for the keyword font.
⚠️ Important: You must set enable inside font to true, because the default value is false.
If you only modify the family without enabling it, the font change will not take effect — so make sure you don’t miss this step.

If the font family is sourced from an external platform, you also need to configure the host.

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
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: Noto Serif SC
size:

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

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

# Font settings for <code> and code blocks.
codes:
external: true
family: Source Code Pro

Enable Copy Button for Code Blocks

In the same _config.yml file, locate the following configuration section.

Set copy_button.enable to true to enable the copy feature.

  • When show_result is set to true, a checkmark will be shown after copying.
  • The style option controls the appearance of the copy button. Choose based on your preference.
1
2
3
4
5
6
7
8
9
10
11
12
13
codeblock:
# Code Highlight theme
# Available values: normal | night | night eighties | night blue | night bright | solarized | solarized dark | galactic
# See: https://github.com/chriskempson/tomorrow-theme
highlight_theme: night eighties

# Add copy button on codeblock
copy_button:
enable: true
# Show text copy result.
show_result: true
# Available values: default | flat | mac
style: mac
-------------本文结束感谢您的阅读-------------