github.com/shohhei1126/hugo@v0.42.2-0.20180623210752-3d5928889ad7/docs/content/en/getting-started/configuration.md (about) 1 --- 2 title: Configure Hugo 3 linktitle: Configuration 4 description: How to configure your Hugo site. 5 date: 2013-07-01 6 publishdate: 2017-01-02 7 lastmod: 2017-03-05 8 categories: [getting started,fundamentals] 9 keywords: [configuration,toml,yaml,json] 10 menu: 11 docs: 12 parent: "getting-started" 13 weight: 60 14 weight: 60 15 sections_weight: 60 16 draft: false 17 aliases: [/overview/source-directory/,/overview/configuration/] 18 toc: true 19 --- 20 21 Hugo uses the `config.toml`, `config.yaml`, or `config.json` (if found in the 22 site root) as the default site config file. 23 24 The user can choose to override that default with one or more site config files 25 using the command line `--config` switch. 26 27 Examples: 28 29 ``` 30 hugo --config debugconfig.toml 31 hugo --config a.toml,b.toml,c.toml 32 ``` 33 34 {{% note %}} 35 Multiple site config files can be specified as a comma-separated string to the `--config` switch. 36 {{% /note %}} 37 38 ## All Configuration Settings 39 40 The following is the full list of Hugo-defined variables with their default 41 value in parentheses. Users may choose to override those values in their site 42 config file(s). 43 44 archetypeDir ("archetypes") 45 : The directory where Hugo finds archetype files (content templates). 46 47 baseURL 48 : Hostname (and path) to the root, e.g. http://bep.is/ 49 50 blackfriday 51 : See [Configure Blackfriday](/getting-started/configuration/#configure-blackfriday) 52 53 buildDrafts (false) 54 : Include drafts when building. 55 56 buildExpired (false) 57 : Include content already expired. 58 59 buildFuture (false) 60 : Include content with publishdate in the future. 61 62 canonifyURLs (false) 63 : Enable to turn relative URLs into absolute. 64 65 contentDir ("content") 66 : The directory from where Hugo reads content files. 67 68 dataDir ("data") 69 : The directory from where Hugo reads data files. 70 71 defaultContentLanguage ("en") 72 : Content without language indicator will default to this language. 73 74 defaultContentLanguageInSubdir (false) 75 : Render the default content language in subdir, e.g. `content/en/`. The site root `/` will then redirect to `/en/`. 76 77 disableHugoGeneratorInject (false) 78 : 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. 79 80 disableKinds ([]) 81 : Enable disabling of all pages of the specified *Kinds*. Allowed values in this list: `"page"`, `"home"`, `"section"`, `"taxonomy"`, `"taxonomyTerm"`, `"RSS"`, `"sitemap"`, `"robotsTXT"`, `"404"`. 82 83 disableLiveReload (false) 84 : Disable automatic live reloading of browser window. 85 86 disablePathToLower (false) 87 : Do not convert the url/path to lowercase. 88 89 enableEmoji (false) 90 : Enable Emoji emoticons support for page content; see the [Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet/). 91 92 enableGitInfo (false) 93 : 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. 94 95 enableMissingTranslationPlaceholders (false) 96 : Show a placeholder instead of the default value or an empty string if a translation is missing. 97 98 enableRobotsTXT (false) 99 : Enable generation of `robots.txt` file. 100 101 frontmatter 102 103 : See [Front matter Configuration](#configure-front-matter). 104 105 footnoteAnchorPrefix ("") 106 : Prefix for footnote anchors. 107 108 footnoteReturnLinkContents ("") 109 : Text to display for footnote return links. 110 111 googleAnalytics ("") 112 : Google Analytics tracking ID. 113 114 hasCJKLanguage (false) 115 : If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will make `.Summary` and `.WordCount` behave correctly for CJK languages. 116 117 imaging 118 : See [Image Processing Config](/content-management/image-processing/#image-processing-config). 119 120 languages 121 : See [Configure Languages](/content-management/multilingual/#configure-languages). 122 123 languageCode ("") 124 : The site's language code. 125 126 disableLanguages 127 : See [Disable a Language](/content-management/multilingual/#disable-a-language) 128 129 layoutDir ("layouts") 130 : The directory from where Hugo reads layouts (templates). 131 132 log (false) 133 : Enable logging. 134 135 logFile ("") 136 : Log File path (if set, logging enabled automatically). 137 138 menu 139 : See [Add Non-content Entries to a Menu](/content-management/menus/#add-non-content-entries-to-a-menu). 140 141 metaDataFormat ("toml") 142 : Front matter meta-data format. Valid values: `"toml"`, `"yaml"`, or `"json"`. 143 144 newContentEditor ("") 145 : The editor to use when creating new content. 146 147 noChmod (false) 148 : Don't sync permission mode of files. 149 150 noTimes (false) 151 : Don't sync modification time of files. 152 153 paginate (10) 154 : Default number of pages per page in [pagination](/templates/pagination/). 155 156 paginatePath ("page") 157 : The path element used during pagination (https://example.com/page/2). 158 159 permalinks 160 : See [Content Management](/content-management/urls/#permalinks). 161 162 pluralizeListTitles (true) 163 : Pluralize titles in lists. 164 165 preserveTaxonomyNames (false) 166 : Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu"). 167 168 publishDir ("public") 169 : The directory to where Hugo will write the final static site (the HTML files etc.). 170 171 pygmentsCodeFencesGuessSyntax (false) 172 : Enable syntax guessing for code fences without specified language. 173 174 pygmentsStyle ("monokai") 175 : Color-theme or style for syntax highlighting. See [Pygments Color Themes](https://help.farbox.com/pygments.html). 176 177 pygmentsUseClasses (false) 178 : Enable using external CSS for syntax highlighting. 179 180 related 181 : See [Related Content](/content-management/related/#configure-related-content). 182 183 relativeURLs (false) 184 : Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs. 185 186 rssLimit (unlimited) 187 : Maximum number of items in the RSS feed. 188 189 sectionPagesMenu ("") 190 : See ["Section Menu for Lazy Bloggers"](/templates/menu-templates/#section-menu-for-lazy-bloggers). 191 192 sitemap 193 : Default [sitemap configuration](/templates/sitemap-template/#configure-sitemap-xml). 194 195 staticDir ("static") 196 : Relative directory from where Hugo reads static files. 197 198 stepAnalysis (false) 199 : Display memory and timing of different steps of the program. 200 201 summaryLength (70) 202 : The length of text to show in a [`.Summary`](/content-management/summaries/#hugo-defined-automatic-summary-splitting). 203 204 taxonomies 205 : See [Configure Taxonomies](/content-management/taxonomies#configure-taxonomies). 206 207 theme ("") 208 : Theme to use (located by default in `/themes/THEMENAME/`). 209 210 themesDir ("themes") 211 : The directory where Hugo reads the themes from. 212 213 timeout (10000) 214 : 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. 215 216 title ("") 217 : Site title. 218 219 uglyURLs (false) 220 : When enabled, creates URL of the form `/filename.html` instead of `/filename/`. 221 222 verbose (false) 223 : Enable verbose output. 224 225 verboseLog (false) 226 : Enable verbose logging. 227 228 watch (false) 229 : Watch filesystem for changes and recreate as needed. 230 231 {{% note %}} 232 If you are developing your site on a \*nix machine, here is a handy shortcut for finding a configuration option from the command line: 233 ``` 234 cd ~/sites/yourhugosite 235 hugo config | grep emoji 236 ``` 237 238 which shows output like 239 240 ``` 241 enableemoji: true 242 ``` 243 {{% /note %}} 244 245 ## Configuration Lookup Order 246 247 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: 248 249 1. `./config.toml` 250 2. `./config.yaml` 251 3. `./config.json` 252 253 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. 254 255 256 ## Example Configuration 257 258 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][]: 259 260 {{< code-toggle file="config">}} 261 baseURL: "https://yoursite.example.com/" 262 title: "My Hugo Site" 263 footnoteReturnLinkContents: "↩" 264 permalinks: 265 post: /:year/:month/:title/ 266 params: 267 Subtitle: "Hugo is Absurdly Fast!" 268 AuthorName: "Jon Doe" 269 GitHubUser: "spf13" 270 ListOfFoo: 271 - "foo1" 272 - "foo2" 273 SidebarRecentLimit: 5 274 {{< /code-toggle >}} 275 276 ## Configure with Environment Variables 277 278 In addition to the 3 config options already mentioned, configuration key-values can be defined through operating system environment variables. 279 280 For example, the following command will effectively set a website's title on Unix-like systems: 281 282 ``` 283 $ env HUGO_TITLE="Some Title" hugo 284 ``` 285 286 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. 287 288 {{% note "Setting Environment Variables" %}} 289 Names must be prefixed with `HUGO_` and the configuration key must be set in uppercase when setting operating system environment variables. 290 {{% /note %}} 291 292 {{< todo >}} 293 Test and document setting params via JSON env var. 294 {{< /todo >}} 295 296 ## Ignore Files When Rendering 297 298 The following statement inside `./config.toml` will cause Hugo to ignore files ending with `.foo` and `.boo` when rendering: 299 300 ``` 301 ignoreFiles = [ "\\.foo$", "\\.boo$" ] 302 ``` 303 304 The above is a list of regular expressions. Note that the backslash (`\`) character is escaped in this example to keep TOML happy. 305 306 ## Configure Front Matter 307 308 ### Configure Dates 309 310 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`. 311 312 313 The default configuration is: 314 315 ```toml 316 [frontmatter] 317 date = ["date","publishDate", "lastmod"] 318 lastmod = [":git" "lastmod", "date","publishDate"] 319 publishDate = ["publishDate", "date"] 320 expiryDate = ["expiryDate"] 321 ``` 322 323 If you, as an example, have a non-standard date parameter in some of your content, you can override the setting for `date`: 324 325 ```toml 326 [frontmatter] 327 date = [ "myDate", ":default"] 328 ``` 329 330 The `:default` is a shortcut to the default settings. The above will set `.Date` to the date value in `myDate` if present, if not we will look in `date`,`publishDate`, `lastmod` and pick the first valid date. 331 332 In the list to the right, values starting with ":" are date handlers with a special meaning (see below). The others are just names of date parameters (case insensitive) in your front matter configuration. Also note that Hugo have some built-in aliases to the above: `lastmod` => `modified`, `publishDate` => `pubdate`, `published` and `expiryDate` => `unpublishdate`. With that, as an example, using `pubDate` as a date in front matter, will, by default, be assigned to `.PublishDate`. 333 334 The special date handlers are: 335 336 337 `:fileModTime` 338 : Fetches the date from the content file's last modification timestamp. 339 340 An example: 341 342 ```toml 343 [frontmatter] 344 lastmod = ["lastmod" ,":fileModTime", ":default"] 345 ``` 346 347 348 The above will try first to extract the value for `.Lastmod` starting with the `lastmod` front matter parameter, then the content file's modification timestamp. The last, `:default` should not be needed here, but Hugo will finally look for a valid date in `:git`, `date` and then `publishDate`. 349 350 351 `:filename` 352 : Fetches the date from the content file's filename. For example, `218-02-22-mypage.md` will extract the date `218-02-22`. Also, if `slug` is not set, `mypage` will be used as the value for `.Slug`. 353 354 An example: 355 356 ```toml 357 [frontmatter] 358 date = [":filename", ":default"] 359 ``` 360 361 The above will try first to extract the value for `.Date` from the filename, then it will look in front matter parameters `date`, `publishDate` and lastly `lastmod`. 362 363 364 `:git` 365 : This is the Git author date for the last revision of this content file. This will only be set if `--enableGitInfo` is set or `enableGitInfo = true` is set in site config. 366 367 ## Configure Blackfriday 368 369 [Blackfriday](https://github.com/russross/blackfriday) is Hugo's built-in Markdown rendering engine. 370 371 Hugo typically configures Blackfriday with sane default values that should fit most use cases reasonably well. 372 373 However, if you have specific needs with respect to Markdown, Hugo exposes some of its Blackfriday behavior options for you to alter. The following table lists these Hugo options, paired with the corresponding flags from Blackfriday's source code ( [html.go](https://github.com/russross/blackfriday/blob/master/html.go) and [markdown.go](https://github.com/russross/blackfriday/blob/master/markdown.go)). 374 375 {{< readfile file="/content/en/readfiles/bfconfig.md" markdown="true" >}} 376 377 {{% note %}} 378 1. Blackfriday flags are *case sensitive* as of Hugo v0.15. 379 2. Blackfriday flags must be grouped under the `blackfriday` key and can be set on both the site level *and* the page level. Any setting on a page will override its respective site setting. 380 {{% /note %}} 381 382 {{< code-toggle file="config" >}} 383 [blackfriday] 384 angledQuotes = true 385 fractions = false 386 plainIDAnchors = true 387 extensions = ["hardLineBreak"] 388 {{< /code-toggle >}} 389 390 ## Configure Additional Output Formats 391 392 Hugo v0.20 introduced the ability to render your content to multiple output formats (e.g., to JSON, AMP html, or CSV). See [Output Formats][] for information on how to add these values to your Hugo project's configuration file. 393 394 ## Configuration Format Specs 395 396 * [TOML Spec][toml] 397 * [YAML Spec][yaml] 398 * [JSON Spec][json] 399 400 [`.Site.Params`]: /variables/site/ 401 [directory structure]: /getting-started/directory-structure 402 [json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation" 403 [lookup order]: /templates/lookup-order/ 404 [Output Formats]: /templates/output-formats/ 405 [templates]: /templates/ 406 [toml]: https://github.com/toml-lang/toml 407 [yaml]: http://yaml.org/spec/