title | linktitle | description | date | publishdate | lastmod | categories | keywords | menu | weight | sections_weight | draft | aliases | toc | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Configure Hugo |
Configuration |
Often the default settings are good enough, but the config file can provide highly granular control over how your site is rendered. |
2013-07-01 |
2017-01-02 |
2017-03-05 |
|
|
|
60 |
60 |
false |
|
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.
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:
./config.toml
./config.yaml
./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.
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 >}}
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: ""
buildDrafts: false
buildFuture: false
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: "config.toml" contentDir: "content" dataDir: "data" defaultExtension: "html" defaultLayout: "post"
defaultContentLanguage: "en"
Renders the default content language in subdir, e.g. /en/. The root directory / will redirect to /en/
defaultContentLanguageInSubdir: false disableLiveReload: false
disableRSS: false
disableSitemap: false
enableGitInfo: false
enableRobotsTXT: false
disable404: false
disableHugoGeneratorInject: false
values = "page", "home", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"
disableKinds: []
disablePathToLower: false ""
enableEmoji: false
enableMissingTranslationPlaceholders: false footnoteAnchorPrefix: "" footnoteReturnLinkContents: ""
googleAnalytics: ""
if true, auto-detect Chinese/Japanese/Korean Languages in the content. (.Summary and .WordCount can work properly in CJKLanguage)
hasCJKLanguage: false languageCode: ""
summaryLength: 70 layoutDir: "layouts"
log: false
logFile: ""
metaDataFormat: "toml" newContentEditor: ""
noChmod: false
noTimes: false
paginate: 10 paginatePath: "page"
permalinks:
pluralizeListTitles: true
preserveTaxonomyNames: false
publishDir: "public"
pygmentsCodeFencesGuessSyntax: false
pygmentsStyle: "monokai"
pygmentsUseClasses: false
rssLimit: 15
SectionPagesMenu: ""
sitemap:
source: "" staticDir: "static"
stepAnalysis: false
templateMetrics: false
themesDir: "themes" theme: "" title: ""
// 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"
uglyURLs: false
verbose: false
verboseLog: false
watch: true taxonomies:
- category: "categories"
- tag: "tags" {{< /code >}}
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 >}}
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 = ""
buildDrafts = false
buildFuture = false
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 = "config.toml" contentDir = "content" dataDir = "data" defaultExtension = "html" defaultLayout = "post"
defaultContentLanguage = "en"
Renders the default content language in subdir, e.g. /en/. The root directory / will redirect to /en/
defaultContentLanguageInSubdir = false disableLiveReload = false
disableRSS = false
disableSitemap = false
enableGitInfo = false
enableRobotsTXT = false
disable404 = false
disableHugoGeneratorInject = false
values = "page", "home", "section", "taxonomy", "taxonomyTerm", "RSS", "sitemap", "robotsTXT", "404"
disableKinds = []
disablePathToLower = false
enableEmoji = false
enableMissingTranslationPlaceholders = false footnoteAnchorPrefix = "" footnoteReturnLinkContents = ""
googleAnalytics = ""
if true, auto-detect Chinese/Japanese/Korean Languages in the content. (.Summary and .WordCount can work properly in CJKLanguage)
hasCJKLanguage = false languageCode = ""
summaryLength = 70 layoutDir = "layouts"
log = false
logFile =
rssLimit = 15
metaDataFormat = "toml" newContentEditor = ""
noChmod = false
noTimes = false
paginate = 10 paginatePath = "page"
permalinks =
pluralizeListTitles = true
preserveTaxonomyNames = false
publishDir = "public"
pygmentsCodeFencesGuessSyntax = false
pygmentsStyle = "monokai"
pygmentsUseClasses = false
SectionPagesMenu =
sitemap =
source = "" staticDir = "static"
stepAnalysis = false
themesDir = "themes" theme = "" title = ""
uglyURLs = false
verbose = false
verboseLog = false
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 %}}
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 %}}
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.
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 and markdown.go).
{{< readfile file="/content/readfiles/bfconfig.md" markdown="true" >}}
{{% note %}}
- Blackfriday flags are case sensitive as of Hugo v0.15.
- 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 >}}
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.