Hugo 配置文件格式支持:hugo.tomlhugo.yamlhugo.json,并按照上述顺序索引,支持根据环境、根配置键、语言拆分单个配置文件。

Hugo Narrow 使用拆分的配置结构,格式采用 YAML

BASH
1exampleSite/
2├── config/
3│   └── _default/
4│       ├── hugo.yaml
5│       ├── languages.yaml
6│       ├── menus.yaml
7│       └── params.yaml
8└── content/
点击展开查看更多

站点配置和一般 Hugo 站点差别不大,较为特殊的是:

  1. permalinks.projects 为项目永久链接设置
  2. outputFormats.WebAppManifest 为主题自动生成 WebAppManifest 配置
  3. highlight.lineNumbersInTable 需要设置为 false
  4. highlight.style 设置不生效,Hugo Narrow 代码块主题更改需更改样式文件。
  5. 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。

版权声明

作者: Hugo Narrow

链接: https://hugo-narrow-docs.vercel.app/zh-cn/docs/basic-config/

许可证: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键