Hugo 配置文件格式支持:hugo.toml、hugo.yaml、hugo.json,并按照上述顺序索引,支持根据环境、根配置键、语言拆分单个配置文件。
注意
访问 Hugo 文档 查看详细内容。
Hugo Narrow 使用拆分的配置结构,格式采用 YAML。
BASH
1exampleSite/
2├── config/
3│ └── _default/
4│ ├── hugo.yaml
5│ ├── languages.yaml
6│ ├── menus.yaml
7│ └── params.yaml
8└── content/站点配置和一般 Hugo 站点差别不大,较为特殊的是:
permalinks.projects为项目永久链接设置outputFormats.WebAppManifest为主题自动生成WebAppManifest配置highlight.lineNumbersInTable需要设置为falsehighlight.style设置不生效,Hugo Narrow 代码块主题更改需更改样式文件。- Hugo 最低版本为 0.146
YAML
1baseURL: https://hugo-narrow.vercel.app/
2languageCode: en-US
3defaultContentLanguage: en
4defaultContentLanguageInSubdir: false
5title: Hugo Narrow
6theme: "hugo-narrow"
7
8hasCJKLanguage: true
9enableEmoji: true
10
11permalinks:
12 posts: /posts/:slug/
13 projects: /projects/:slug/
14 pages: /:slug/
15
16pagination:
17 pagerSize: 6
18 path: "page"
19
20taxonomies:
21 category: categories
22 tag: tags
23 series: series
24
25markup:
26 tableOfContents:
27 startLevel: 2
28 endLevel: 4
29 ordered: false
30 goldmark:
31 renderer:
32 unsafe: true
33 extensions:
34 extras:
35 delete:
36 enable: true
37 insert:
38 enable: true
39 mark:
40 enable: true
41 subscript:
42 enable: false
43 superscript:
44 enable: false
45 strikethrough: false
46 highlight:
47 codeFences: true
48 guessSyntax: false
49 lineNos: false
50 lineNumbersInTable: false # 设置为 false
51 noClasses: false
52 style: github # 不需要更改
53 tabWidth: 2
54
55outputs:
56 home: ["HTML", "RSS", "JSON", "WebAppManifest"]
57
58# 自定义输出格式
59outputFormats:
60 WebAppManifest:
61 mediaType: "application/manifest+json"
62 baseName: "site"
63 isPlainText: true
64
65module:
66 hugoVersion:
67 extended: true
68 min: 0.146.0主要 Sections
Hugo Narrow 可以配置搜索索引的 Sections,用于全局搜索。
config/_default/hugo.yaml
1mainSections: ["posts", "projects", "pages"]主页最近文章列表会使用第一个 Section。