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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
---
title: Configure Hugo
linktitle: Configuration
description: How to configure your Hugo site.
date: 2013-07-01
publishdate: 2017-01-02
lastmod: 2017-03-05
categories: [getting started,fundamentals]
keywords: [configuration,toml,yaml,json]
menu:
docs:
parent: "getting-started"
weight: 60
weight: 60
sections_weight: 60
draft: false
aliases: [/overview/source-directory/,/overview/configuration/]
toc: true
---
## Configuration File
Hugo uses the `config.toml`, `config.yaml`, or `config.json` (if found in the
site root) as the default site config file.
The user can choose to override that default with one or more site config files
using the command line `--config` switch.
Examples:
```
hugo --config debugconfig.toml
hugo --config a.toml,b.toml,c.toml
```
{{% note %}}
Multiple site config files can be specified as a comma-separated string to the `--config` switch.
{{% /note %}}
{{< todo >}}TODO: distinct config.toml and others (the root object files){{< /todo >}}
## Configuration Directory
In addition to using a single site config file, one can use the `configDir` directory (default to `config/`) to maintain easier organization and environment specific settings.
- Each file represents a configuration root object, such as `params.toml` for `[Params]`, `menu(s).toml` for `[Menu]`, `languages.toml` for `[Languages]` etc...
- Each file's content must be top-level, for example:
In `config.toml` is:
```toml
[Params]
foo = "bar"
```
In `params.toml` is:
```
foo = "bar"
```
- Each directory holds a group of files containing settings unique to an environment.
- Files can be localized to become language specific.
```
├── config
│ ├── _default
│ │ ├── config.toml
│ │ ├── languages.toml
│ │ ├── menus.en.toml
│ │ ├── menus.zh.toml
│ │ └── params.toml
│ ├── production
│ │ ├── config.toml
│ │ └── params.toml
│ └── staging
│ ├── config.toml
│ └── params.toml
```
Considering the structure above, when running `hugo --environment staging`, Hugo will use every settings from `config/_default` and merge `staging`'s on top of those.
{{% note %}}
Default environments are __development__ with `hugo server` and __production__ with `hugo`.
{{%/ note %}}
## All Configuration Settings
The following is the full list of Hugo-defined variables with their default
value in parentheses. Users may choose to override those values in their site
config file(s).
archetypeDir ("archetypes")
: The directory where Hugo finds archetype files (content templates). {{% module-mounts-note %}}
assetDir ("assets")
: The directory where Hugo finds asset files used in [Hugo Pipes](/hugo-pipes/). {{% module-mounts-note %}}
baseURL
: Hostname (and path) to the root, e.g. https://bep.is/
blackfriday
: See [Configure Blackfriday](/getting-started/configuration-markup#blackfriday)
build
: See [Configure Build](#configure-build)
buildDrafts (false)
: Include drafts when building.
buildExpired (false)
: Include content already expired.
buildFuture (false)
: Include content with publishdate in the future.
caches
: See [Configure File Caches](#configure-file-caches)
canonifyURLs (false)
: Enable to turn relative URLs into absolute.
contentDir ("content")
: The directory from where Hugo reads content files. {{% module-mounts-note %}}
dataDir ("data")
: The directory from where Hugo reads data files. {{% module-mounts-note %}}
defaultContentLanguage ("en")
: Content without language indicator will default to this language.
defaultContentLanguageInSubdir (false)
: Render the default content language in subdir, e.g. `content/en/`. The site root `/` will then redirect to `/en/`.
disableAliases (false)
: Will disable generation of alias redirects. Note that even if `disableAliases` is set, the aliases themselves are preserved on the page. The motivation with this is to be able to generate 301 redirects in an `.htaccess`, a Netlify `_redirects` file or similar using a custom output format.
disableHugoGeneratorInject (false)
: Hugo will, by default, inject a generator meta tag in the HTML head on the _home page only_. You can turn it off, but we would really appreciate if you don't, as this is a good way to watch Hugo's popularity on the rise.
disableKinds ([])
: Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"term"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`.
disableLiveReload (false)
: Disable automatic live reloading of browser window.
disablePathToLower (false)
: Do not convert the url/path to lowercase.
enableEmoji (false)
: Enable Emoji emoticons support for page content; see the [Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet/).
enableGitInfo (false)
: Enable `.GitInfo` object for each page (if the Hugo site is versioned by Git). This will then update the `Lastmod` parameter for each page using the last git commit date for that content file.
enableInlineShortcodes (false)
: Enable inline shortcode support. See [Inline Shortcodes](/templates/shortcode-templates/#inline-shortcodes).
enableMissingTranslationPlaceholders (false)
: Show a placeholder instead of the default value or an empty string if a translation is missing.
enableRobotsTXT (false)
: Enable generation of `robots.txt` file.
frontmatter
: See [Front matter Configuration](#configure-front-matter).
footnoteAnchorPrefix ("")
: Prefix for footnote anchors.
footnoteReturnLinkContents ("")
: Text to display for footnote return links.
googleAnalytics ("")
: Google Analytics tracking ID.
hasCJKLanguage (false)
: If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will make `.Summary` and `.WordCount` behave correctly for CJK languages.
imaging
: See [Image Processing Config](/content-management/image-processing/#image-processing-config).
languages
: See [Configure Languages](/content-management/multilingual/#configure-languages).
languageCode ("")
: The site's language code. It is used in the default [RSS template](/templates/rss/#configure-rss) and can be useful for [multi-lingual sites](/content-management/multilingual/#configure-multilingual-multihost).
languageName ("")
: The site's language name.
disableLanguages
: See [Disable a Language](/content-management/multilingual/#disable-a-language)
layoutDir ("layouts")
: The directory from where Hugo reads layouts (templates).
log (false)
: Enable logging.
logFile ("")
: Log File path (if set, logging enabled automatically).
markup
: See [Configure Markup](/getting-started/configuration-markup).{{< new-in "0.60.0" >}}
menu
: See [Add Non-content Entries to a Menu](/content-management/menus/#add-non-content-entries-to-a-menu).
minify
: See [Configure Minify](#configure-minify)
module
: Module config see [Module Config](/hugo-modules/configuration/).{{< new-in "0.56.0" >}}
newContentEditor ("")
: The editor to use when creating new content.
noChmod (false)
: Don't sync permission mode of files.
noTimes (false)
: Don't sync modification time of files.
paginate (10)
: Default number of elements per page in [pagination](/templates/pagination/).
paginatePath ("page")
: The path element used during pagination (https://example.com/page/2).
permalinks
: See [Content Management](/content-management/urls/#permalinks).
pluralizeListTitles (true)
: Pluralize titles in lists.
publishDir ("public")
: The directory to where Hugo will write the final static site (the HTML files etc.).
related
: See [Related Content](/content-management/related/#configure-related-content).{{< new-in "0.27" >}}
relativeURLs (false)
: Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
refLinksErrorLevel ("ERROR")
: When using `ref` or `relref` to resolve page links and a link cannot resolved, it will be logged with this logg level. Valid values are `ERROR` (default) or `WARNING`. Any `ERROR` will fail the build (`exit -1`).
refLinksNotFoundURL
: URL to be used as a placeholder when a page reference cannot be found in `ref` or `relref`. Is used as-is.
rssLimit (unlimited)
: Maximum number of items in the RSS feed.
sectionPagesMenu ("")
: See ["Section Menu for Lazy Bloggers"](/templates/menu-templates/#section-menu-for-lazy-bloggers).
sitemap
: Default [sitemap configuration](/templates/sitemap-template/#configure-sitemap-xml).
staticDir ("static")
: A directory or a list of directories from where Hugo reads [static files][static-files]. {{% module-mounts-note %}}
summaryLength (70)
: The length of text in words to show in a [`.Summary`](/content-management/summaries/#hugo-defined-automatic-summary-splitting).
taxonomies
: See [Configure Taxonomies](/content-management/taxonomies#configure-taxonomies).
theme ("")
: Theme to use (located by default in `/themes/THEMENAME/`).
themesDir ("themes")
: The directory where Hugo reads the themes from.
timeout (10000)
: Timeout for generating page contents, in milliseconds (defaults to 10 seconds). *Note:* this is used to bail out of recursive content generation, if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents) you might need to raise this limit.
title ("")
: Site title.
titleCaseStyle ("AP")
: See [Configure Title Case](#configure-title-case)
uglyURLs (false)
: When enabled, creates URL of the form `/filename.html` instead of `/filename/`.
verbose (false)
: Enable verbose output.
verboseLog (false)
: Enable verbose logging.
watch (false)
: Watch filesystem for changes and recreate as needed.
{{% note %}}
If you are developing your site on a \*nix machine, here is a handy shortcut for finding a configuration option from the command line:
```
cd ~/sites/yourhugosite
hugo config | grep emoji
```
which shows output like
```
enableemoji: true
```
{{% /note %}}
## Configure Build
{{< new-in "0.66.0" >}}
The `build` configuration section contains global build-related configuration options.
{{< code-toggle file="config">}}
[build]
useResourceCacheWhen="fallback"
writeStats = false
noJSConfigInAssets = false
{{< /code-toggle >}}
useResourceCacheWhen
: When to use the cached resources in `/resources/_gen` for PostCSS and ToCSS. Valid values are `never`, `always` and `fallback`. The last value means that the cache will be tried if PostCSS/extended version is not available.
writeStats {{< new-in "0.69.0" >}}
: When enabled, a file named `hugo_stats.json` will be written to your project root with some aggregated data about the build, e.g. list of HTML entities published to be used to do [CSS pruning](/hugo-pipes/postprocess/#css-purging-with-postcss). If you're only using this for the production build, you should consider placing it below [config/production](/getting-started/configuration/#configuration-directory). It's also worth mentioning that, due to the nature of the partial server builds, new HTML entities will be added when you add or change them while the server is running, but the old values will not be removed until you restart the server or run a regular `hugo` build.
noJSConfigInAssets {{< new-in "0.78.0" >}}
: Turn off writing a `jsconfig.js` into your `/assets` folder with mapping of imports from running [js.Build](https://gohugo.io/hugo-pipes/js). This file is intended to help with intellisense/navigation inside code editors such as [VS Code](https://code.visualstudio.com/). Note that if you do not use `js.Build`, no file will be written.
## Configure Server
{{< new-in "0.67.0" >}}
This is only relevant when running `hugo server`, and it allows to set HTTP headers during development, which allows you to test out your Content Security Policy and similar. The configuration format matches [Netlify's](https://docs.netlify.com/routing/headers/#syntax-for-the-netlify-configuration-file) with slighly more powerful [Glob matching](https://github.com/gobwas/glob):
{{< code-toggle file="config">}}
[server]
[[server.headers]]
for = "/**.html"
[server.headers.values]
X-Frame-Options = "DENY"
X-XSS-Protection = "1; mode=block"
X-Content-Type-Options = "nosniff"
Referrer-Policy = "strict-origin-when-cross-origin"
Content-Security-Policy = "script-src localhost:1313"
{{< /code-toggle >}}
Since this is is "development only", it may make sense to put it below the `development` environment:
{{< code-toggle file="config/development/server">}}
[[headers]]
for = "/**.html"
[headers.values]
X-Frame-Options = "DENY"
X-XSS-Protection = "1; mode=block"
X-Content-Type-Options = "nosniff"
Referrer-Policy = "strict-origin-when-cross-origin"
Content-Security-Policy = "script-src localhost:1313"
{{< /code-toggle >}}
{{< new-in "0.72.0" >}}
You can also specify simple redirects rules for the server. The syntax is again similar to Netlify's.
Note that a `status` code of 200 will trigger a [URL rewrite](https://docs.netlify.com/routing/redirects/rewrites-proxies/), which is what you want in SPA situations, e.g:
{{< code-toggle file="config/development/server">}}
[[redirects]]
from = "/myspa/**"
to = "/myspa/"
status = 200
force = false
{{< /code-toggle >}}
{{< new-in "0.76.0" >}} Setting `force=true` will make a redirect even if there is existing content in the path. Note that before Hugo 0.76 `force` was the default behaviour, but this is inline with how Netlify does it.
## Configure Title Case
Set `titleCaseStyle` to specify the title style used by the [title](/functions/title/) template function and the automatic section titles in Hugo. It defaults to [AP Stylebook](https://www.apstylebook.com/) for title casing, but you can also set it to `Chicago` or `Go` (every word starts with a capital letter).
## Configuration Environment Variables
HUGO_NUMWORKERMULTIPLIER
: Can be set to increase or reduce the number of workers used in parallel processing in Hugo. If not set, the number of logical CPUs will be used.
## Configuration Lookup Order
Similar to the template [lookup order][], Hugo has a default set of rules for searching for a configuration file in the root of your website's source directory as a default behavior:
1. `./config.toml`
2. `./config.yaml`
3. `./config.json`
In your `config` file, you can direct Hugo as to how you want your website rendered, control your website's menus, and arbitrarily define site-wide parameters specific to your project.
## Example Configuration
The following is a typical example of a configuration file. The values nested under `params:` will populate the [`.Site.Params`][] variable for use in [templates][]:
{{< code-toggle file="config">}}
baseURL: "https://yoursite.example.com/"
title: "My Hugo Site"
footnoteReturnLinkContents: "↩"
permalinks:
posts: /:year/:month/:title/
params:
Subtitle: "Hugo is Absurdly Fast!"
AuthorName: "Jon Doe"
GitHubUser: "spf13"
ListOfFoo:
- "foo1"
- "foo2"
SidebarRecentLimit: 5
{{< /code-toggle >}}
## Configure with Environment Variables
In addition to the 3 config options already mentioned, configuration key-values can be defined through operating system environment variables.
For example, the following command will effectively set a website's title on Unix-like systems:
```
$ env HUGO_TITLE="Some Title" hugo
```
This is really useful if you use a service such as Netlify to deploy your site. Look at the Hugo docs [Netlify configuration file](https://github.com/gohugoio/hugoDocs/blob/master/netlify.toml) for an example.
{{% note "Setting Environment Variables" %}}
Names must be prefixed with `HUGO_` and the configuration key must be set in uppercase when setting operating system environment variables.
To set config params, prefix the name with `HUGO_PARAMS_`
{{% /note %}}
{{< new-in "0.79.0" >}} If you are using snake_cased variable names, the above will not work, so since Hugo 0.79.0 Hugo determines the delimiter to use by the first character after `HUGO`. This allows you to define environment variables on the form `HUGOxPARAMSxAPI_KEY=abcdefgh`, using any [allowed](https://stackoverflow.com/questions/2821043/allowed-characters-in-linux-environment-variable-names#:~:text=So%20names%20may%20contain%20any,not%20begin%20with%20a%20digit.) delimiter.
{{< todo >}}
Test and document setting params via JSON env var.
{{< /todo >}}
## Ignore Content Files When Rendering
The following statement inside `./config.toml` will cause Hugo to ignore content files ending with `.foo` and `.boo` when rendering:
```
ignoreFiles = [ "\\.foo$", "\\.boo$" ]
```
The above is a list of regular expressions. Note that the backslash (`\`) character is escaped in this example to keep TOML happy.
## Configure Front Matter
### Configure Dates
Dates are important in Hugo, and you can configure how Hugo assigns dates to your content pages. You do this by adding a `frontmatter` section to your `config.toml`.
The default configuration is:
```toml
[frontmatter]
date = ["date", "publishDate", "lastmod"]
lastmod = [":git", "lastmod", "date", "publishDate"]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]
```
If you, as an example, have a non-standard date parameter in some of your content, you can override the setting for `date`:
```toml
[frontmatter]
date = ["myDate", ":default"]
```
The `:default` is a shortcut to the default settings. The above will set `.Date` to
|