f9a5dc59b Code Toggle block added to doc site final batch Templates ✅ Variables ✅ 4d4107968 Add eSolia as new sponsor 000fed94e Add missing closing tags for li in menu template example f462b620f Clarify that local CSV files cannot be inside data dir ae083641a Added hugo-search-index to list of search tools e2b64d0b7 Remove extra link 2fb4c9af5 Release 0.38.2 59b1c9853 releaser: Prepare repository for 0.39-DEV 92f6a05ea releaser: Add release notes to /docs for release of 0.38.2 76244729e releaser: Bump versions for release of 0.38.2 0960c5fb3 Adjust gray color of tab vs pane in code-toggle. 8ae3aadd7 use code-toggle shortcode when relevant Content Management ✅ 455b8b53b Update related.md 6e8d19090 Release 0.38.1 079ba044c releaser: Prepare repository for 0.39-DEV 6f23e6ec1 releaser: Add release notes to /docs for release of 0.38.1 c51692ceb releaser: Bump versions for release of 0.38.1 d37ea6a5e Update related.md faa2707d0 Update index.md 9ce901dcb Add a forgotten language tag (go-html-template) for code b05aaed14 Update where.md 4d4760819 Fix typo in code-toggle.md c5a5250a1 Use the new go-html-template Chroma lexer 2de831f4b Add the full list of Chroma lexers 18114d4b4 Update Output Formats b069d7f84 Release 0.38 caaa8355a releaser: Prepare repository for 0.39-DEV e45b7cc9f releaser: Add release notes to /docs for release of 0.38 40f40906e releaser: Bump versions for release of 0.38 2d52e2e4e Merge commit 'ed8bf081fdbf336e026517b7e1b123c039014ab5' 1439f64a0 docs: Generate docshelper data 5b0edfd79 Add .Site.IsServer fdb579ad1 Merge commit '0a23baa6a90901f772c234107c4f12c16c76f4aa' 7b71da1f8 hugolib: Add Reset method to delete key from Scratch 63a131664 docs: Add docs for lang.Merge 55cba056d Merge commit '3886fc1fef6ac19d58b9ba1bb642d0c6c9a54031' 6f301ebcc docs: Add docs on the new front matter configuration 7ba35ef56 Merge commit 'c0290655825e7bb36e13fb39f89d85b392cf1adc' 3d2cab754 releaser: Prepare repository for 0.38-DEV 095e888e1 releaser: Add release notes to /docs for release of 0.37.1 593fa0dcb releaser: Bump versions for release of 0.37.1 c18c1df54 releaser: Prepare repository for 0.38-DEV git-subtree-dir: docs git-subtree-split: f9a5dc59b77d15cc2c7534e10bcd90bcfeda7bb4
13 KiB
title | linktitle | description | date | publishdate | lastmod | categories | keywords | menu | weight | sections_weight | draft | aliases | toc | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Configure Hugo | Configuration | How to configure your Hugo site. | 2013-07-01 | 2017-01-02 | 2017-03-05 |
|
|
|
60 | 60 | false |
|
true |
Hugo uses the config.toml
, config.yaml
, or config.json
(if found in the
site root) as the default site config file.
The user can choose to override that default with one or more site config files
using the command line --config
switch.
Examples:
hugo --config debugconfig.toml
hugo --config a.toml,b.toml,c.toml
{{% note %}}
Multiple site config files can be specified as a comma-separated string to the --config
switch.
{{% /note %}}
All Configuration Settings
The following is the full list of Hugo-defined variables with their default value in parentheses. Users may choose to override those values in their site config file(s).
- archetypeDir ("archetypes")
- The directory where Hugo finds archetype files (content templates).
- baseURL
- Hostname (and path) to the root, e.g. http://bep.is/
- blackfriday
- See Configure Blackfriday
- buildDrafts (false)
- Include drafts when building.
- buildExpired (false)
- Include content already expired.
- buildFuture (false)
- Include content with publishdate in the future.
- canonifyURLs (false)
- Enable to turn relative URLs into absolute.
- contentDir ("content")
- The directory from where Hugo reads content files.
- dataDir ("data")
- The directory from where Hugo reads data files.
- defaultContentLanguage ("en")
- Content without language indicator will default to this language.
- defaultContentLanguageInSubdir (false)
- Render the default content language in subdir, e.g.
content/en/
. The site root/
will then redirect to/en/
. - disableHugoGeneratorInject (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 ([])
- Enable disabling of all pages of the specified Kinds. Allowed values in this list:
"page"
,"home"
,"section"
,"taxonomy"
,"taxonomyTerm"
,"RSS"
,"sitemap"
,"robotsTXT"
,"404"
. - disableLiveReload (false)
- Disable automatic live reloading of browser window.
- disablePathToLower (false)
- Do not convert the url/path to lowercase.
- enableEmoji (false)
- Enable Emoji emoticons support for page content; see the Emoji Cheat Sheet.
- enableGitInfo (false)
- Enable
.GitInfo
object for each page (if the Hugo site is versioned by Git). This will then update theLastmod
parameter for each page using the last git commit date for that content file. - enableMissingTranslationPlaceholders (false)
- Show a placeholder instead of the default value or an empty string if a translation is missing.
- enableRobotsTXT (false)
- Enable generation of
robots.txt
file. - frontmatter
- footnoteAnchorPrefix ("")
- Prefix for footnote anchors.
- footnoteReturnLinkContents ("")
- Text to display for footnote return links.
- googleAnalytics ("")
- Google Analytics tracking ID.
- hasCJKLanguage (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 Config.
- languages
- See Configure Languages.
- languageCode ("")
- The site's language code.
- disableLanguages
- See Disable a Language
- layoutDir ("layouts")
- The directory from where Hugo reads layouts (templates).
- log (false)
- Enable logging.
- logFile ("")
- Log File path (if set, logging enabled automatically).
- menu
- See Add Non-content Entries to a Menu.
- metaDataFormat ("toml")
- Front matter meta-data format. Valid values:
"toml"
,"yaml"
, or"json"
. - newContentEditor ("")
- The editor to use when creating new content.
- noChmod (false)
- Don't sync permission mode of files.
- noTimes (false)
- Don't sync modification time of files.
- paginate (10)
- Default number of pages per page in pagination.
- paginatePath ("page")
- The path element used during pagination (https://example.com/page/2).
- permalinks
- See Content Management.
- pluralizeListTitles (true)
- Pluralize titles in lists.
- preserveTaxonomyNames (false)
- Preserve special characters in taxonomy names ("Gérard Depardieu" vs "Gerard Depardieu").
- publishDir ("public")
- The directory to where Hugo will write the final static site (the HTML files etc.).
- pygmentsCodeFencesGuessSyntax (false)
- Enable syntax guessing for code fences without specified language.
- pygmentsStyle ("monokai")
- Color-theme or style for syntax highlighting. See Pygments Color Themes.
- pygmentsUseClasses (false)
- Enable using external CSS for syntax highlighting.
- related
- See Related Content.
- relativeURLs (false)
- Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
- rssLimit (unlimited)
- Maximum number of items in the RSS feed.
- sectionPagesMenu ("")
- See "Section Menu for Lazy Bloggers".
- sitemap
- Default sitemap configuration.
- staticDir ("static")
- Relative directory from where Hugo reads static files.
- stepAnalysis (false)
- Display memory and timing of different steps of the program.
- summaryLength (70)
- The length of text to show in a
.Summary
. - taxonomies
- See Configure Taxonomies.
- theme ("")
- Theme to use (located by default in
/themes/THEMENAME/
). - themesDir ("themes")
- The directory where Hugo reads the themes from.
- title ("")
- Site title.
- uglyURLs (false)
- When enabled, creates URL of the form
/filename.html
instead of/filename/
. - verbose (false)
- Enable verbose output.
- verboseLog (false)
- Enable verbose logging.
- watch (false)
- Watch filesystem for changes and recreate as needed.
{{% 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 %}}
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:
./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.
Example Configuration
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:
{{< code-toggle file="config">}} 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-toggle >}}
Configure with Environment 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
This is really useful if you use a service such as Netlify to deploy your site. Look at the Hugo docs Netlify configuration file for an example.
{{% 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 %}}
{{< todo >}} Test and document setting params via JSON env var. {{< /todo >}}
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 Front Matter
Configure Dates
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
.
The default configuration is:
[frontmatter]
date = ["date","publishDate", "lastmod"]
lastmod = [":git" "lastmod", "date","publishDate"]
publishDate = ["publishDate", "date"]
expiryDate = ["expiryDate"]
If you, as an example, have a non-standard date parameter in some of your content, you can override the setting for date
:
[frontmatter]
date = [ "myDate", ":default"]
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.
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
.
The special date handlers are:
:fileModTime
- Fetches the date from the content file's last modification timestamp.
An example:
[frontmatter]
lastmod = ["lastmod" ,":fileModTime", ":default"]
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
.
:filename
- Fetches the date from the content file's filename. For example,
218-02-22-mypage.md
will extract the date218-02-22
. Also, ifslug is not set,
mypagewill be used as the value for
.Slug`.
An example:
[frontmatter]
date = [":filename", ":default"]
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
.
:git
- This is the Git author date for the last revision of this content file. This will only be set if
--enableGitInfo
is set orenableGitInfo = true
is set in site config.
Configure Blackfriday
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-toggle file="config" >}} [blackfriday] angledQuotes = true fractions = false plainIDAnchors = true extensions = ["hardLineBreak"] {{< /code-toggle >}}
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.