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
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
|
---
title: Configure Hugo
linkTitle: Configuration
description: How to configure your Hugo site.
categories: [fundamentals,getting started]
keywords: [configuration,toml,yaml,json]
menu:
docs:
parent: getting-started
weight: 40
weight: 40
aliases: [/overview/source-directory/,/overview/configuration/]
toc: true
---
## Configuration file
Hugo uses the `hugo.toml`, `hugo.yaml`, or `hugo.json` (if found in the
site root) as the default site configuration file.
The user can choose to override that default with one or more site configuration files using the command-line `--config` switch.
Examples:
```txt
hugo --config debugconfig.toml
hugo --config a.toml,b.toml,c.toml
```
{{% note %}}
Multiple site configuration files can be specified as a comma-separated string to the `--config` switch.
{{% /note %}}
## hugo.toml vs config.toml
In Hugo 0.110.0 we changed the default configuration base file name to `hugo`, e.g. `hugo.toml`. We will still look for `config.toml` etc., but we recommend you eventually rename it (but you need to wait if you want to support older Hugo versions). The main reason we're doing this is to make it easier for code editors and build tools to identify this as a Hugo configuration file and project.
{{< new-in "0.110.0" >}}
## Configuration directory
In addition to using a single site configuration 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:
{{< code-toggle file="hugo" >}}
[Params]
foo = "bar"
{{< /code-toggle >}}
{{< code-toggle file="params" >}}
foo = "bar"
{{< /code-toggle >}}
- Each directory holds a group of files containing settings unique to an environment.
- Files can be localized to become language specific.
```txt
├── config
│ ├── _default
│ │ ├── hugo.toml
│ │ ├── languages.toml
│ │ ├── menus.en.toml
│ │ ├── menus.zh.toml
│ │ └── params.toml
│ ├── production
│ │ ├── hugo.toml
│ │ └── params.toml
│ └── staging
│ ├── hugo.toml
│ └── params.toml
```
Considering the structure above, when running `hugo --environment staging`, Hugo will use every setting from `config/_default` and merge `staging`'s on top of those.
Let's take an example to understand this better. Let's say you are using Google Analytics for your website. This requires you to specify `googleAnalytics = "G-XXXXXXXX"` in `hugo.toml`. Now consider the following scenario:
- You don't want the Analytics code to be loaded in development i.e. in your `localhost`
- You want to use separate googleAnalytics IDs for your production & staging environments (say):
- `G-PPPPPPPP` for production
- `G-SSSSSSSS` for staging
This is how you need to configure your `hugo.toml` files considering the above scenario:
1. In `_default/hugo.toml` you don't need to mention `googleAnalytics` parameter at all. This ensures that no Google Analytics code is loaded in your development server i.e. when you run `hugo server`. This works since, by default Hugo sets `Environment=development` when you run `hugo server` which uses the configuration files from `_default` folder
2. In `production/hugo.toml` you just need to have one line:
```googleAnalytics = "G-PPPPPPPP"```
You don't need to mention all other parameters like `title`, `baseURL`, `theme` etc. again in this configuration file. You need to mention only those parameters which are different or new for the production environment. This is due to the fact that Hugo is going to __merge__ this on top of `_default/hugo.toml`. Now when you run `hugo` (build command), by default hugo sets `Environment=production`, so the `G-PPPPPPPP` analytics code will be there in your production website
3. Similarly in `staging/hugo.toml` you just need to have one line:
```googleAnalytics = "G-SSSSSSSS"```
Now you need to tell Hugo that you are using the staging environment. So your build command should be `hugo --environment staging` which will load the `G-SSSSSSSS` analytics code in your staging website
{{% note %}}
Default environments are __development__ with `hugo server` and __production__ with `hugo`.
{{%/ note %}}
## Merge configuration from themes
The configuration value for `_merge` can be one of:
none
: No merge.
shallow
: Only add values for new keys.
deep
: Add values for new keys, merge existing.
Note that you don't need to be so verbose as in the default setup below; a `_merge` value higher up will be inherited if not set.
{{< code-toggle file="hugo" dataKey="config_helpers.mergeStrategy" skipHeader=true />}}
## All configuration settings
The following is the full list of Hugo-defined variables. Users may choose to override those values in their site configuration file(s).
### archetypeDir
**Default value:** "archetypes"
The directory where Hugo finds archetype files (content templates). {{% module-mounts-note %}}
### assetDir
**Default value:** "assets"
The directory where Hugo finds asset files used in [Hugo Pipes](/hugo-pipes/). {{% module-mounts-note %}}
### baseURL
The absolute URL (protocol, host, path, and trailing slash) of your published site (e.g., `https://www.example.org/docs/`).
### build
See [Configure Build](#configure-build)
### buildDrafts (false)
**Default value:** false
Include drafts when building.
### buildExpired
**Default value:** false
Include content already expired.
### buildFuture
**Default value:** false
Include content with publishdate in the future.
### caches
See [Configure File Caches](#configure-file-caches)
### cascade
Pass down default configuration values (front matter) to pages in the content tree. The options in site configuration is the same as in page front matter, see [Front Matter Cascade](/content-management/front-matter#front-matter-cascade).
### canonifyURLs
**Default value:** false
Enable to turn relative URLs into absolute. See [details](/content-management/urls/#canonical-urls).
### cleanDestinationDir
**Default value:** false
When building, removes files from destination not found in static directories.
### contentDir
**Default value:** "content"
The directory from where Hugo reads content files. {{% module-mounts-note %}}
### copyright
**Default value:** ""
Copyright notice for your site, typically displayed in the footer.
### dataDir
**Default value:** "data"
The directory from where Hugo reads data files. {{% module-mounts-note %}}
### defaultContentLanguage
**Default value:** "en"
Content without language indicator will default to this language.
### defaultContentLanguageInSubdir
**Default value:** false
Render the default content language in subdir, e.g. `content/en/`. The site root `/` will then redirect to `/en/`.
### disableAliases
**Default value:** 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
**Default value:** 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
**Default value:** []
Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"term"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`.
### disableLiveReload
**Default value:** false
Disable automatic live reloading of browser window.
### disablePathToLower
**Default value:** false
Do not convert the url/path to lowercase.
### enableEmoji
**Default value:** false
Enable Emoji emoticons support for page content; see the [Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet/).
### enableGitInfo
**Default value:** 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
**Default value:** false
Enable inline shortcode support. See [Inline Shortcodes](/templates/shortcode-templates/#inline-shortcodes).
### enableMissingTranslationPlaceholders
**Default value:** false
Show a placeholder instead of the default value or an empty string if a translation is missing.
### enableRobotsTXT
**Default value:** false
Enable generation of `robots.txt` file.
### frontmatter
See [Front matter Configuration](#configure-front-matter).
### googleAnalytics
**Default value:** ""
Google Analytics tracking ID.
### hasCJKLanguage
**Default value:** 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 configuration](/content-management/image-processing/#imaging-configuration).
### languageCode
**Default value:** ""
A language tag as defined by [RFC 5646](https://datatracker.ietf.org/doc/html/rfc5646). This value is used to populate:
- The `<language>` element in the internal [RSS template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/_default/rss.xml)
- The `lang` attribute of the `<html>` element in the internal [alias template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/alias.html)
### languages
See [Configure Languages](/content-management/multilingual/#configure-languages).
### disableLanguages
See [Disable a Language](/content-management/multilingual/#disable-a-language)
### markup
See [Configure Markup](/getting-started/configuration-markup).
### mediaTypes
See [Configure Media Types](/templates/output-formats/#media-types).
### menus
See [Menus](/content-management/menus/#define-in-site-configuration).
### minify
See [Configure Minify](#configure-minify)
### module
Module configuration see [module configuration](/hugo-modules/configuration/).
### newContentEditor
**Default value:** ""
The editor to use when creating new content.
### noChmod
**Default value:** false
Don't sync permission mode of files.
### noTimes
**Default value:** false
Don't sync modification time of files.
### outputFormats
See [Configure Output Formats](#configure-additional-output-formats).
### paginate
**Default value:** 10
Default number of elements per page in [pagination](/templates/pagination/).
### paginatePath
**Default value:** "page"
The path element used during pagination (`https://example.com/page/2`).
### permalinks
See [Content Management](/content-management/urls/#permalinks).
### pluralizeListTitles
**Default value:** true
Pluralize titles in lists.
### publishDir
**Default value:** "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).
### relativeURLs
**Default value:** false
Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs. See [details](/content-management/urls/#relative-urls).
### refLinksErrorLevel
**Default value:** "ERROR"
When using `ref` or `relref` to resolve page links and a link cannot be resolved, it will be logged with this log 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.
### removePathAccents
**Default value:** false
Removes [non-spacing marks](https://www.compart.com/en/unicode/category/Mn) from [composite characters](https://en.wikipedia.org/wiki/Precomposed_character) in content p
|