Hugo博客的配置文件

Hugo博客的配置文件介绍

配置文件说明

在博客文件夹中,配置文件将从下面四个路径中查找,优先级从高到低(假设采用FixIt主题):

  1. hugo.toml
  2. config/_default
  3. themes/FixIt/hugo.toml
  4. themes/FixIt/config/_default

hugo.toml文件和config/_default文件夹至少存在一个,二者都存在则依据优先级。

提示

hugo server命令的运行结果中,会列出当前博客所使用的配置文件,如下

1
Watching for config changes in /Users/star/Github/Blog/config/_default, /Users/star/Github/Blog/themes/FixIt/hugo.toml

示例

比如当前配置如下:

 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
baseURL = "https://star927.github.io/"
title = "Huxley's Blog"
theme = "FixIt"

[menu]
  [[menu.main]]
    identifier = "categories"
    name = "分类"
    url = "/categories/"
    weight = 2
    [menu.main.params]
      icon = "fa-solid fa-folder-open"
  [[menu.main]]
    identifier = "tags"
    name = "标签"
    url = "/tags/"
    weight = 3
    [menu.main.params]
      icon = "fa-solid fa-tags"

[params]
  # FixIt theme version
  version = "0.3.X" # e.g. "0.2.X", "0.2.15", "v0.2.15" etc.
  description = "This is my new Hugo FixIt site"
  [params.author]
    name = "Huxley"
    email = ""
    link = "https://star927.github.io/"
    avatar = "/images/avatar.svg"

将所有配置都放在hugo.toml文件中,该文件就会太长,可删除该文件,并创建config/_default/hugo.tomlconfig/_default/menu.tomlconfig/_default/params.toml文件,如下所示:

1
2
3
baseURL = "https://star927.github.io/"
title = "Huxley's Blog"
theme = "FixIt"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
[[main]]
identifier = "categories"
name = "分类"
url = "/categories/"
weight = 2
[main.params]
  icon = "fa-solid fa-folder-open"
[[main]]
identifier = "tags"
name = "标签"
url = "/tags/"
weight = 3
[main.params]
  icon = "fa-solid fa-tags"
1
2
3
4
5
6
7
8
# FixIt theme version
version = "0.3.X" # e.g. "0.2.X", "0.2.15", "v0.2.15" etc.
description = "This is my new Hugo FixIt site"
[author]
name = "Huxley"
email = ""
link = "https://star927.github.io/"
avatar = "/images/avatar.svg"

使用这三个文件与使用上面的hugo.toml文件是等效的。


相关内容

0%