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