設定ファイル(hugo.toml

 1# /hugo.toml もしくは
 2# /config/_default/hugo.toml
 3
 4baseURL = "https://example.com/sub/"
 5title = "サイト全体のタイトル"
 6theme = ["テーマ名"]
 7
 8# サイト言語の設定
 9defaultContentLanguage = "ja"
10defaultContentLanguageInSubdir = false
11hasCJKLanguage = true
12
13# サイトのオプション
14enableEmoji = true
15enableGitInfo = false
16enableMissingTranslationPlaceholder = true
17enableRobotsTXT = true
18
19# ビルド時のオプション設定
20buildDrafts = true
21buildFuture = true
22timeout = "30s"
23
24# パーマリンク設定
25[permalinks]
26pages = "/:section/:filename"
27posts = "/:section/:year/:yearday"
28
29# タクソノミーの設定
30[taxonomies]
31tag = "tags"
32category = "categories"
33author = "authors"
34
35# ページ割の設定
36[pagination]
37pageSize = 20
38
39# ビルドするファイルの設定
40[outputs]
41home = ["HTML", "RSS", "JSON"]
42
43# GAの設定
44[services]
45[services.googleAnalytics]
46ID = "G-測定タグID"
47
48# プライバシー設定
49[privacy]
50[privacy.googleAnalytics]
51disable = true
52respectDoNotTrack = true

サイトの設定はhugo.tomlに記述します。 設定の形式はTOML / YAML / JSONが利用できます。 僕はTOML形式を使っています。

注意

v0.110からデフォルトの設定ファイル名がhugo.tomlに変更されました。 しばらくはconfig.tomlも使えるようですが、hugo.tomlに変更することが推奨されています。 詳しくはhugo.toml vs config.toml - Hugoドキュメントを参照してください。

設定セクション名

設定できるセクション(root configuration keys)は

  1. build

  2. caches

  3. cascade

  4. deployment

  5. frontmatter

  6. imaging

  7. languages

  8. markup

  9. mediatypes

  10. menus

  11. minify

  12. module

  13. outputformats

  14. outputs

  15. params

  16. permalinks

  17. privacy

  18. related

  19. security

  20. segments

  21. server

  22. services

  23. sitemap

  24. taxonomies

です。

たくさんのセクションがありますが、 すべてにHugoのデフォルト設定が用意されています。 カスタムしたいセクションのみ設定ファイルに追加すればOKです。