使用hexo theme遇到的问题
2025-07-24  / issue  / hexo

前言

如果你使用Alternate-Theme-Config,可能会出现许多奇怪的问题。强烈建议在将主题的 _config.yml 文件复制为 _config.[theme].yml 后立即取消注释。否则,你可能会遇到以下问题。

自定义的404页没有生效

2025-8-15 更新,该问题与特定主题有关,不属于Alternate-Theme-Config的锅。

问题发生在将原来的主题orange换成arch后,线上的404页不是我的,变成了arch提供的404.html,我自定义404页在[lang]/404/index.html。因为多语言站点根目录public下只能有一个404.html,为了使用我的自定义404页,需要修改build脚本将[lang]/404/index.html复制到public下,lang选择en还是zh-CN取决于你想要用哪种语言的404页,这里我用的en。

以下是 package.json 中构建脚本的变更。您可以将 en 更改为您想要的语言。

1
2
3
"scripts": {
"build": "hexo clean && hexo generate && cp public/en/404/index.html public/404.html"
}

两个about导航菜单

以下配置中出现了两个about导航菜单,其中Friends导航菜单已被移除,但可能会被主题默认开启的about插入。我怀疑这是由某种主题配置合并引起的。
解决方案:即使不需要的配置,也请设置enable: false

同一个nav出现多次
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
# _config.oranges.yml
navbar:
-
name: Home
enable: true
path: /
key: home
-
name: Archives
enable: true
path: /archives/
key: archives
-
name: Categories
enable: true
path: /categories/
key: categories
-
name: Tags
enable: true
path: /tags/
key: tags
# 解除下面注释即可解决重复的
# -
# name: Friends
# enable: false
-
name: About
enable: true
path: /about/
key: about

意外的主题作者的邮箱

同样,愚蠢的 Alternate-Theme-Config 导致 _config.[theme].yml 文件中的某些字段被主题的 _config.yml 文件覆盖。
我的 _config.[theme].yml 文件不包含邮箱地址,但主题的 _config.yml 文件包含,这导致主题作者的邮箱地址在我的网站中显示。

1
2
3
4
5
6
7
8
9
10
11
12
13
# _config.arch.yml
footer:
# social: 社交方式
social:
# name: 名称
# icon: 图标,目前仅支持IconFont部分图标
# path: 地址

# Uncomment as needed to enable / 按需取消注释以启用
-
name: github
icon: github
path: https://github.com/Jim-Elijah