hugo/content/getting-started/configuration.md
Bjørn Erik Pedersen 374d184e67 Squashed 'docs/' changes from f97826a17..1dc05a16b
1dc05a16b Update index.md
d73a9b3b4 Added StackImpact showcase
b0e82b3a5 Fix uglyURLs example
cf8a93728 GA track outgoing sponsor clikcs
aca59ac66 Move the sponsor banners up a little
5571673f0 Migrate from analytics.js to gtag.js
64a29b6cb Update faq.md
84704aa84 Use GOPATH variable if defined in installation from source
5f70e6ee2 Remove disableRSS etc. from the documentation
4945e7937 Remove superflous asterisks
39f6c9c28 showcase: Add 1password.com
fe0f82610 Add GitLab warning
9f26f21d2 Fix URL typo
83a91fc99 Remove duplicate release notes
133cdd313 Release 0.36.1
fbe2a2dc7 Clean images
1b02f9193 Merge branch 'temp361'
c430d2d58 Merge branch 'release-0.36.1'
dd7370fc4 releaser: Prepare repository for 0.37-DEV
72534f9ec releaser: Add release notes to /docs for release of 0.36.1
845b2cacb releaser: Bump versions for release of 0.36.1
78790fcb1 Add fluid type to showcase details box
4ef59e008 Adjust column widths to handle a wider variety of copy width
6d2e68521 Always show the latest showcase item on front page
665b1eb5e showcase: Shuffle the news items
5fef1f9b7 Escape quote
d680f0c16 Add some quotes
1722f0d5a showcase: Make the description more about Hugo
a9d43db0a Add Quiply Employee Communications App
7aaa464ec Add Quiply Employee Communications App
fad6a25dd maintenance: Show last 30
7afcfdced showcase: Set Linode date to today
0c31f481a New showcase for Linode
6c7687c2d Minor edits to the `apply` documentation
04bbff8b3 Update apply.md
f543032e3 Fix clunky sentence
218ba2a65 Some more Netlify improvements
0bd512125 Improve the Netlify versioning docs
7a708d60e Clarify Netlify's Hugo versions handling
8f86342cd Add some space
d68d4ff37 Remove now superflous warning
bf93a46ea maintenance: Add TODO list
3b5f27835 maintenance: Remove a superflous prefix
8f29ba2fb maintenance: Adjust order
105d53610 maintenance: Add TOC
29e86396b maintenance: Fix page list selection
ba51fe66d Finish the Maintenance  section
e9b0c710c Add latest changes in new spotlight section
8ccd79f61 Fix broken sentence
c77643c37 Spelling
919f2faef Remove some old troubleshooting articles
09e467f06 Add a new FAQ
ac2b25bb5 Hartwell showcase typos
5bf766993 Trim "www." from shocase URLs in title
a180cd5cb Make the inline showcase template names unique
6886982fd Merge commit '9cc9bab46288d8d5f9fda7009c5f746258cec1b4'
09728efbf Add "target" and "rel" parameters to figure shortcode

git-subtree-dir: docs
git-subtree-split: 1dc05a16bd6b99809d97daeda743d914297f908c
2018-02-21 10:00:31 +01:00

385 lines
15 KiB
Markdown

---
title: Configure Hugo
linktitle: Configuration
description: Often the default settings are good enough, but the config file can provide highly granular control over how your site is rendered.
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
---
The [directory structure][] of a Hugo website—or more precisely, the source organization of files containing the website's content and templates—provides most of the configuration information that Hugo needs in order to generate a finished website.
Because of Hugo's sensible defaults, many websites may not need a configuration file. Hugo is designed to recognize certain typical usage patterns.
## 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.
## YAML Configuration
The following is a typical example of a YAML configuration file. The values nested under `params:` will populate the [`.Site.Params`][] variable for use in [templates][]:
{{< code file="config.yml">}}
baseURL: "https://yoursite.example.com/"
title: "My Hugo Site"
footnoteReturnLinkContents: "↩"
permalinks:
post: /:year/:month/:title/
params:
Subtitle: "Hugo is Absurdly Fast!"
AuthorName: "Jon Doe"
GitHubUser: "spf13"
ListOfFoo:
- "foo1"
- "foo2"
SidebarRecentLimit: 5
{{< /code >}}
### All Variables, YAML
The following is the full list of Hugo-defined variables in an example YAML file. The values provided in this example represent the default values used by Hugo.
{{< code file="config.yml" download="config.yml" >}}
archetypeDir: "archetypes"
# hostname (and path) to the root, e.g. http://spf13.com/
baseURL: ""
# include content marked as draft
buildDrafts: false
# include content with publishdate in the future
buildFuture: false
# include content already expired
buildExpired: false
# enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs. See the "URL Management" page
relativeURLs: false
canonifyURLs: false
# config file (default is path/config.yaml|json|toml)
config: "config.toml"
contentDir: "content"
dataDir: "data"
defaultLayout: "post"
# Missing translations will default to this content language
defaultContentLanguage: "en"
# Renders the default content language in subdir, e.g. /en/. The root directory / will redirect to /en/
defaultContentLanguageInSubdir: false
disableLiveReload: false
# Enable GitInfo feature
enableGitInfo: false
# Build robots.txt file
enableRobotsTXT: false
# Do not inject generator meta tag on homepage
disableHugoGeneratorInject: false
# Allows you to disable all page types and will render nothing related to 'kind';
# values = "page", "home", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"
disableKinds: []
# Do not make the url/path to lowercase
disablePathToLower: false ""
# Enable Emoji emoticons support for page content; see emoji-cheat-sheet.com
enableEmoji: false
# Show a placeholder instead of the default value or an empty string if a translation is missing
enableMissingTranslationPlaceholders: false
footnoteAnchorPrefix: ""
footnoteReturnLinkContents: ""
# google analytics tracking id
googleAnalytics: ""
# if true, auto-detect Chinese/Japanese/Korean Languages in the content. (.Summary and .WordCount can work properly in CJKLanguage)
hasCJKLanguage: false
languageCode: ""
# the length of text to show in a .Summary
summaryLength: 70
layoutDir: "layouts"
# Enable Logging
log: false
# Log File path (if set, logging enabled automatically)
logFile: ""
# "toml","yaml", or "json"
metaDataFormat: "toml"
newContentEditor: ""
# Don't sync permission mode of files
noChmod: false
# Don't sync modification time of files
noTimes: false
# Pagination
paginate: 10
paginatePath: "page"
# See "content-management/permalinks"
permalinks:
# Pluralize titles in lists using inflect
pluralizeListTitles: true
# Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu")
preserveTaxonomyNames: false
# filesystem path to write files to
publishDir: "public"
# enables syntax guessing for code fences without specified language
pygmentsCodeFencesGuessSyntax: false
# color-codes for highlighting derived from this style
pygmentsStyle: "monokai"
# true use pygments-css or false will color code directly
pygmentsUseClasses: false
# maximum number of items in the RSS feed
rssLimit: 15
# see "Section Menu for Lazy Bloggers", /templates/menu-templates for more info
SectionPagesMenu: ""
# default sitemap configuration map
sitemap:
# filesystem path to read files relative from
source: ""
staticDir: "static"
# display memory and timing of different steps of the program
stepAnalysis: false
# display metrics about template executions
templateMetrics: false
# theme to use (located by default in /themes/THEMENAME/)
themesDir: "themes"
theme: ""
title: ""
# Title Case style guide for the title func and other automatic title casing in Hugo.
// Valid values are "AP" (default), "Chicago" and "Go" (which was what you had in Hugo <= 0.25.1).
// See https://www.apstylebook.com/ and http://www.chicagomanualofstyle.org/home.html
titleCaseStyle: "AP"
# if true, use /filename.html instead of /filename/
uglyURLs: false
# verbose output
verbose: false
# verbose logging
verboseLog: false
# watch filesystem for changes and recreate as needed
watch: true
taxonomies:
- category: "categories"
- tag: "tags"
{{< /code >}}
## TOML Configuration
The following is an example of a TOML configuration file. The values under `[params]` will populate the `.Site.Params` variable for use in [templates][]:
{{< code file="config.toml">}}
contentDir = "content"
layoutDir = "layouts"
publishDir = "public"
buildDrafts = false
baseURL = "https://yoursite.example.com/"
canonifyURLs = true
title = "My Hugo Site"
[taxonomies]
category = "categories"
tag = "tags"
[params]
subtitle = "Hugo is Absurdly Fast!"
author = "John Doe"
{{< /code >}}
### All Variables, TOML
The following is the full list of Hugo-defined variables in an example TOML file. The values provided in this example represent the default values used by Hugo.
{{< code file="config.toml" download="config.toml">}}
archetypeDir = "archetypes"
# hostname (and path) to the root, e.g. http://spf13.com/
baseURL = ""
# include content marked as draft
buildDrafts = false
# include content with publishdate in the future
buildFuture = false
# include content already expired
buildExpired = false
# enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
relativeURLs = false
canonifyURLs = false
# config file (default is path/config.yaml|json|toml)
config = "config.toml"
contentDir = "content"
dataDir = "data"
defaultLayout = "post"
# Missing translations will default to this content language
defaultContentLanguage = "en"
# Renders the default content language in subdir, e.g. /en/. The root directory / will redirect to /en/
defaultContentLanguageInSubdir = false
disableLiveReload = false
# Enable GitInfo feature
enableGitInfo = false
# Build robots.txt file
enableRobotsTXT = false
# Do not inject generator meta tag on homepage
disableHugoGeneratorInject = false
# Allows you to disable all page types and will render nothing related to 'kind';
# values = "page", "home", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"
disableKinds = []
# Do not make the url/path to lowercase
disablePathToLower = false
# Enable Emoji emoticons support for page content; see emoji-cheat-sheet.com
enableEmoji = false
# Show a placeholder instead of the default value or an empty string if a translation is missing
enableMissingTranslationPlaceholders = false
footnoteAnchorPrefix = ""
footnoteReturnLinkContents = ""
# google analytics tracking id
googleAnalytics = ""
# if true, auto-detect Chinese/Japanese/Korean Languages in the content. (.Summary and .WordCount can work properly in CJKLanguage)
hasCJKLanguage = false
languageCode = ""
# the length of text to show in a .Summary
summaryLength = 70
layoutDir = "layouts"
# Enable Logging
log = false
# Log File path (if set, logging enabled automatically)
logFile =
# maximum number of items in the RSS feed
rssLimit = 15
# "toml","yaml", or "json"
metaDataFormat = "toml"
newContentEditor = ""
# Don't sync permission mode of files
noChmod = false
# Don't sync modification time of files
noTimes = false
# Pagination
paginate = 10
paginatePath = "page"
# See "content-management/permalinks"
permalinks =
# Pluralize titles in lists using inflect
pluralizeListTitles = true
# Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu")
preserveTaxonomyNames = false
# filesystem path to write files to
publishDir = "public"
# enables syntax guessing for code fences without specified language
pygmentsCodeFencesGuessSyntax = false
# color-codes for highlighting derived from this style
pygmentsStyle = "monokai"
# true: use pygments-css or false: color-codes directly
pygmentsUseClasses = false
# see "Section Menu for Lazy Bloggers", /templates/menu-templates for more info
SectionPagesMenu =
# default sitemap configuration map
sitemap =
# filesystem path to read static files relative from
staticDir = "static"
# display memory and timing of different steps of the program
stepAnalysis = false
# theme to use (located by default in /themes/THEMENAME/)
themesDir = "themes"
theme = ""
title = ""
# if true, use /filename.html instead of /filename/
uglyURLs = false
# verbose output
verbose = false
# verbose logging
verboseLog = false
# watch filesystem for changes and recreate as needed
watch = true
[taxonomies]
category = "categories"
tag = "tags"
{{< /code >}}
{{% 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 %}}
## Environmental 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
```
{{% 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.
{{% /note %}}
## Ignore Files When Rendering
The following statement inside `./config.toml` will cause Hugo to ignore 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 Blackfriday
[Blackfriday](https://github.com/russross/blackfriday) is Hugo's built-in Markdown rendering engine.
Hugo typically configures Blackfriday with sane default values that should fit most use cases reasonably well.
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)).
{{< readfile file="/content/readfiles/bfconfig.md" markdown="true" >}}
{{% note %}}
1. Blackfriday flags are *case sensitive* as of Hugo v0.15.
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.
{{% /note %}}
{{< code file="bf-config.toml" >}}
[blackfriday]
angledQuotes = true
fractions = false
plainIDAnchors = true
extensions = ["hardLineBreak"]
{{< /code >}}
{{< code file="bf-config.yml" >}}
blackfriday:
angledQuotes: true
fractions: false
plainIDAnchors: true
extensions:
- hardLineBreak
{{< /code >}}
## Configure Additional Output Formats
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.
## Configuration Format Specs
* [TOML Spec][toml]
* [YAML Spec][yaml]
* [JSON Spec][json]
[`.Site.Params`]: /variables/site/
[directory structure]: /getting-started/directory-structure
[json]: https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf "Specification for JSON, JavaScript Object Notation"
[lookup order]: /templates/lookup-order/
[Output Formats]: /templates/output-formats/
[templates]: /templates/
[toml]: https://github.com/toml-lang/toml
[yaml]: http://yaml.org/spec/