32cb8785e Fix page weights in content management section (#1896) 11977b96f Make relURL and related functions consistent (#1895) f12180207 Clarify github deployment (#1894) 958877789 Remove remaining references to Highlight.js (#1893) fc487d263 Minor edit to taxonomy page 3b6a224b2 Update theme b28553b62 Change "flavor" to "edition" when referring to builds (#1892) 660e7581c Replaced sudo in OpenBSD with doas (#1891) e3fcdea10 fix a few minor grammatical issues on Firebase docs (#1889) e4c8b30eb update Static Web Apps docs (#1890) da2197c9e Update hosting-on-firebase.md (#1347) 5f2a0c271 Adding deployment guide for Azure Static Web Apps (#1456) 5aaf570cd add Azure Static Web App config to 404 template 35fc54362 add Azure Static Web App config to 404 template d48f67ba1 Update 01-flavors.md 11debae8d Cleaned Use of ref and relref section, added refs of index.md and _in… (#1744) b77604078 docs: Add link to menu entry variables (#1827) 0fa8a6bf0 Misc copy edits (#1887) c27b545ac Improve explanation of safeHTMLAttr's function (#1503) b04a4b32e Make CLI command summaries meaningful (#1886) dbf00a81f Fix a typo in diagrams documentation (#1885) 11f884327 docs: Clarify how to remove draft/future/expired content (#1831) 6dc9e9860 Improve complement function (#1884) 56448a51a Remove erroneous sourcemap desc (#1883) a0d0d2829 Merge branch 'divinerites-patch-1' 10f20cb5e Add a plausible-hugo theme component 9f1413eb5 Minor edits to showcase example 7d78420db fix broken link to Isso Comments 925cb291f Make directory tree consistent with other examples 300fff092 Add link to security policy from getenv.md (#1746) 7b4c517a6 Fix docs menu weights ce35775e0 Update faq.md (#1763) f3fb791a4 Remove dated new-in flags (#1879) b6c634629 Remove deprecated templating langs (#1880) 1b25ca34f Update the findRE and replaceRE functions (#1881) 28757ec73 Add Alora Labs website to showcase (#1494) e3c4bc4e7 Remove unimplemented "ugly" property 86afd84ff Update editors.md (#1878) 44c093911 Add urlquery function docs (#1633) 16a8c3548 Update links to installation page (#1876) 9e357f078 Add missing sections to BSD installation page (#1875) 1b1291634 Promote "Installation" to a section 9dd51235b Add detail to description of .Plain page variable (#1870) d333d0287 Minor markdown linting fix and URL updates (#1873) d57c8aa50 Remove extraneous apostrophe (#1871) 8c25cfc5c Update index.md 09fea41e0 Add lang to fenced code block 35b904798 Add small documentation about .Site.Social.twitter variable (#1854) 672042f89 Consolidate site configuration dfd4dd873 Add help.ampio.com showcase. (#1863) e8d0e7bdf Include link to internal templates code (#1794) 7db6f0c01 Add example to split function (#1867) be87dba80 Clarify split function docs (#1792) a079193f1 Fix typo on data templates page b234c70ee Fix data templates page (#1855) 074232b45 Update front-matter.md (#1856) 711c8fa80 Added missing default value (#1862) 034762882 Fixed some grammar issues and typos (#1865) 764574a4d Fix spelling error 2698f2d44 update URLs to prevent redirects (#1864) 68f05fdc8 Fenced code blocks should have a language specified (#1861) 24393315b GitHub Workflows security hardening (#1859) 3eeee13bf Markdown formatting: Add Fenced code block languages (#1858) e152cdf1f netlify: Hugo 0.105.0 4c7fc9f7e Merge branch 'tempv0.105.0' d16710afc Change anchor reference to use relref function calls (#1853) f52af8e4a tpl/encoding: Add noHTMLEscape option to jsonify eca0046c4 Update hosting-on-keycdn docs (#1852) ffbe17a48 Add note for rsync deploy command (#1415) c482133f1 docs: Update quick start to clarify the need of extended version (#1828) 1e3b33804 use correct URL for Google Search console verification (#1851) dac034f63 Markdown and formatting fixes (#1850) 43f177e3c Fix LiveReload in quick-start (#1739) f78deaa5f Add link for ''Hugo Shortcode Syntax Highlighting' VS Code extension (#1765) 08087ecd7 Remove some hidden pages (#1848) b6cb5ae48 Markdown linting fixes (#1846) 527ec5941 Update hugo.md (#1742) 83e8f2168 Clarify that a shortcode with .Inner must be closed (#1785) 4193f4445 Add Super Linter GitHub Action (#1845) fd91bfe1a Formatting and grammar fixes (#1844) ab5a49c49 Create codeql-analysis GitHub Action (#1812) 63b3e082e Add tutorial on using fusejs to search examples (#1756) 54c253ab0 Note that Google Universal Analytics are deprecated (#1770) 385fa77c6 Update articles.toml (#1840) 5e336bd26 Replace awkward wording (ESL?) (#1842) 2446ad349 Added Introduction to Hugo tutorial/video series (#1736) 7b21b2e76 Don't use self-closing generator tag ef73712ff Image processing. available methods: add method 'Colors' (#1837) 018f83bbe [comment platform] - add new alternative (#1751) 5636c208b Grammar and spelling fixes (#1836) 3f2e26f77 Change link of repojacking vulnerable link - JekyllToHugo (#1834) 301379fc3 fix: use shorter image URL to make it easier to read (#1835) de5fa7b30 Update search.md to include Pagefind (#1826) e9d72bcda Breadcrumb example: add basic accessibility (#1832) 6cffff87a netlify: Hugo 0.104.3 892360f61 Update output-formats.md 09a7a46ae Remove my defunct and little used migrator (#1824) 347434cca netlify: Hugo 0.104.2 f8c721162 Update postcss.md c2baf7155 netlify: Hugo 0.104.1 05d1192cd Update diagrams.md (#1823) 3c43a8bbe netlify: Hugo 0.104.0 57973b334 Merge branch 'tempv0.104.0' da775a36d docs: Regen docs helper ae48b5901 docs: Regenerate CLI docs af4a823b1 resources/images: Add $image.Colors 8e3f9ca64 Remove outdated IE conditional comments example (#1821) d1a84701b fix typo in template introduction (#1820) c0c7339e0 Update internal.md 17aefc515 Remove the recommendation about where to put the GA tempalte 263297236 Adjust GA template instructions 1cc265d99 Update the GA template usage section e11968338 config/security: Allow proxy variables in subcommands 9218ab993 netlify: Hugo 0.103.1 0b0e890d1 Update markdownify and RenderString documentation (#1818) 50f5d4776 Fix internal link (#1817) 6beb443c5 netlify: Hugo 0.103.0 14b5af248 Merge branch 'tempv0.103.0' 548e7aa62 server: Add 404 support 3a20aa0ba Update theme git-subtree-dir: docs git-subtree-split: 32cb8785ea74d5b82f2e2bea79d059cab497902a
26 KiB
title | linktitle | description | date | publishdate | categories | keywords | menu | weight | sections_weight | aliases | toc | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Configure Hugo | Configuration | How to configure your Hugo site. | 2013-07-01 | 2017-01-02 |
|
|
|
60 | 60 |
|
true |
Configuration File
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 %}}
{{< todo >}}TODO: distinct config.toml and others (the root object files){{< /todo >}}
Configuration Directory
In addition to using a single site config file, one can use the configDir
directory (default to config/
) to maintain easier organization and environment specific settings.
- Each file represents a configuration root object, such as
params.toml
for[Params]
,menu(s).toml
for[Menu]
,languages.toml
for[Languages]
etc... - Each file's content must be top-level, for example:
{{< code-toggle file="config" >}} [Params] foo = "bar" {{< /code-toggle >}}
{{< code-toggle file="params" >}} foo = "bar" {{< /code-toggle >}}
- Each directory holds a group of files containing settings unique to an environment.
- Files can be localized to become language specific.
├── config
│ ├── _default
│ │ ├── config.toml
│ │ ├── languages.toml
│ │ ├── menus.en.toml
│ │ ├── menus.zh.toml
│ │ └── params.toml
│ ├── production
│ │ ├── config.toml
│ │ └── params.toml
│ └── staging
│ ├── config.toml
│ └── params.toml
Considering the structure above, when running hugo --environment staging
, Hugo will use every setting from config/_default
and merge staging
's on top of those.
Let's take an example to understand this better. Let's say you are using Google Analytics for your website. This requires you to specify googleAnalytics = "G-XXXXXXXX"
in config.toml
. Now consider the following scenario:
- You don't want the Analytics code to be loaded in development i.e. in your
localhost
- You want to use separate googleAnalytics IDs for your production & staging environments (say):
G-PPPPPPPP
for productionG-SSSSSSSS
for staging
This is how you need to configure your config.toml
files considering the above scenario:
-
In
_default/config.toml
you don't need to mentiongoogleAnalytics
parameter at all. This ensures that no Google Analytics code is loaded in your development server i.e. when you runhugo serve
. This works since, by default Hugo setsEnvironment=development
when you runhugo serve
which uses the config files from_default
folder -
In
production/config.toml
you just need to have one line:googleAnalytics = "G-PPPPPPPP"
You don't need to mention all other parameters like
title
,baseURL
,theme
etc. again in this config file. You need to mention only those parameters which are different or new for the production environment. This is due to the fact that Hugo is going to merge this on top of_default/config.toml
. Now when you runhugo
(build command), by default hugo setsEnvironment=production
, so theG-PPPPPPPP
analytics code will be there in your production website -
Similarly in
staging/config.toml
you just need to have one line:googleAnalytics = "G-SSSSSSSS"
Now you need to tell Hugo that you are using the staging environment. So your build command should be
hugo --environment staging
which will load theG-SSSSSSSS
analytics code in your staging website
{{% note %}}
Default environments are development with hugo server
and production with hugo
.
{{%/ note %}}
Merge Configuration from Themes
The configuration value for _merge
can be one of:
- none
- No merge.
- shallow
- Only add values for new keys.
- deep
- Add values for new keys, merge existing.
Note that you don't need to be so verbose as in the default setup below; a _merge
value higher up will be inherited if not set.
{{< code-toggle config="mergeStrategy" skipHeader=true />}}
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
Default value: "archetypes"
The directory where Hugo finds archetype files (content templates). {{% module-mounts-note %}}
assetDir
Default value: "assets"
The directory where Hugo finds asset files used in Hugo Pipes. {{% module-mounts-note %}}
baseURL
Hostname (and path) to the root, e.g. https://bep.is/
build
See Configure Build
buildDrafts (false)
Default value: false
Include drafts when building.
buildExpired
Default value: false
Include content already expired.
buildFuture
Default value: false
Include content with publishdate in the future.
caches
cascade
Pass down default configuration values (front matter) to pages in the content tree. The options in site config is the same as in page front matter, see Front Matter Cascade.
canonifyURLs
Default value: false
Enable to turn relative URLs into absolute.
contentDir
Default value: "content"
The directory from where Hugo reads content files. {{% module-mounts-note %}}
copyright
Default value: ""
Copyright notice for your site, typically displayed in the footer.
dataDir
Default value: "data"
The directory from where Hugo reads data files. {{% module-mounts-note %}}
defaultContentLanguage
Default value: "en"
Content without language indicator will default to this language.
defaultContentLanguageInSubdir
Default value: false
Render the default content language in subdir, e.g. content/en/
. The site root /
will then redirect to /en/
.
disableAliases
Default value: false
Will disable generation of alias redirects. Note that even if disableAliases
is set, the aliases themselves are preserved on the page. The motivation with this is to be able to generate 301 redirects in an .htaccess
, a Netlify _redirects
file or similar using a custom output format.
disableHugoGeneratorInject
Default value: 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
Default value: []
Enable disabling of all pages of the specified Kinds. Allowed values in this list: "page"
, "home"
, "section"
, "taxonomy"
, "term"
, "RSS"
, "sitemap"
, "robotsTXT"
, "404"
.
disableLiveReload
Default value: false
Disable automatic live reloading of browser window.
disablePathToLower
- Default value: false
-
Do not convert the url/path to lowercase.
enableEmoji
Default value: false
Enable Emoji emoticons support for page content; see the Emoji Cheat Sheet.
enableGitInfo
Default value: false
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.
enableInlineShortcodes
Default value: false
Enable inline shortcode support. See Inline Shortcodes.
enableMissingTranslationPlaceholders
Default value: false
Show a placeholder instead of the default value or an empty string if a translation is missing.
enableRobotsTXT
Default value: false
Enable generation of robots.txt
file.
frontmatter
See Front matter Configuration.
googleAnalytics
Default value: ""
Google Analytics tracking ID.
hasCJKLanguage
Default value: false
If true, auto-detect Chinese/Japanese/Korean Languages in the content. This will make .Summary
and .WordCount
behave correctly for CJK languages.
imaging
languageCode
Default value: ""
A language tag as defined by RFC 5646. This value is used to populate:
- The
<language>
element in the internal RSS template - The
lang
attribute of the<html>
element in the internal alias template
languages
See Configure Languages.
disableLanguages
markup
See Configure Markup.
mediaTypes
menus
See Add Non-content Entries to a Menu.
minify
See Configure Minify
module
Module config see Module Config.
newContentEditor
Default value: ""
The editor to use when creating new content.
noChmod
Default value: false
Don't sync permission mode of files.
noTimes
Default value: false
Don't sync modification time of files.
outputFormats
paginate
Default value: 10
Default number of elements per page in pagination.
paginatePath
Default value: "page"
The path element used during pagination (https://example.com/page/2
).
permalinks
See Content Management.
pluralizeListTitles
Default value: true
Pluralize titles in lists.
publishDir
Default value: "public"
The directory to where Hugo will write the final static site (the HTML files etc.).
related
: See Related Content.
relativeURLs
Default value: false
Enable this to make all relative URLs relative to content root. Note that this does not affect absolute URLs.
refLinksErrorLevel
Default value: "ERROR"
When using ref
or relref
to resolve page links and a link cannot be resolved, it will be logged with this log level. Valid values are ERROR
(default) or WARNING
. Any ERROR
will fail the build (exit -1
).
refLinksNotFoundURL
URL to be used as a placeholder when a page reference cannot be found in ref
or relref
. Is used as-is.
removePathAccents
Default value: false
Removes non-spacing marks from composite characters in content paths.
content/post/hügó.md --> https://example.org/post/hugo/
rssLimit
Default value: -1 (unlimited)
Maximum number of items in the RSS feed.
sectionPagesMenu
See "Section Menu for Lazy Bloggers".
security
See Security Policy
sitemap
Default sitemap configuration.
summaryLength
Default value: 70
The length of text in words to show in a .Summary
.
taxonomies
See Configure Taxonomies.
theme
: See Module Config for how to import a theme.
themesDir
Default value: "themes"
The directory where Hugo reads the themes from.
timeout
Default value: "30s"
Timeout for generating page contents, specified as a duration or in milliseconds. Note: this is used to bail out of recursive content generation. You might need to raise this limit if your pages are slow to generate (e.g., because they require large image processing or depend on remote contents).
timeZone
The time zone (or location), e.g. Europe/Oslo
, used to parse front matter dates without such information and in the time
function. The list of valid values may be system dependent, but should include UTC
, Local
, and any location in the IANA Time Zone database.
title
Site title.
titleCaseStyle
Default value: "AP"
uglyURLs
Default value: false
When enabled, creates URL of the form /filename.html
instead of /filename/
.
watch
Default value: 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 %}}
Configure Build
The build
configuration section contains global build-related configuration options.
{{< code-toggle file="config">}} [build] useResourceCacheWhen="fallback" writeStats = false noJSConfigInAssets = false {{< /code-toggle >}}
- useResourceCacheWhen
- When to use the cached resources in
/resources/_gen
for PostCSS and ToCSS. Valid values arenever
,always
andfallback
. The last value means that the cache will be tried if PostCSS/extended version is not available. - writeStats
- When enabled, a file named
hugo_stats.json
will be written to your project root with some aggregated data about the build, e.g. list of HTML entities published to be used to do CSS pruning. If you're only using this for the production build, you should consider placing it below config/production. It's also worth mentioning that, due to the nature of the partial server builds, new HTML entities will be added when you add or change them while the server is running, but the old values will not be removed until you restart the server or run a regularhugo
build.
Note that the prime use case for this is purging of unused CSS; it is built for speed and there may be false positives (e.g., detection of HTML elements that are not HTML elements).
- noJSConfigInAssets
- Turn off writing a
jsconfig.json
into your/assets
folder with mapping of imports from running js.Build. This file is intended to help with intellisense/navigation inside code editors such as VS Code. Note that if you do not usejs.Build
, no file will be written.
Configure Server
This is only relevant when running hugo server
, and it allows to set HTTP headers during development, which allows you to test out your Content Security Policy and similar. The configuration format matches Netlify's with slightly more powerful Glob matching:
{{< code-toggle file="config">}} [server] server.headers for = "/**"
[server.headers.values] X-Frame-Options = "DENY" X-XSS-Protection = "1; mode=block" X-Content-Type-Options = "nosniff" Referrer-Policy = "strict-origin-when-cross-origin" Content-Security-Policy = "script-src localhost:1313" {{< /code-toggle >}}
Since this is "development only", it may make sense to put it below the development
environment:
{{< code-toggle file="config/development/server">}} headers for = "/**"
[headers.values] X-Frame-Options = "DENY" X-XSS-Protection = "1; mode=block" X-Content-Type-Options = "nosniff" Referrer-Policy = "strict-origin-when-cross-origin" Content-Security-Policy = "script-src localhost:1313" {{< /code-toggle >}}
You can also specify simple redirects rules for the server. The syntax is again similar to Netlify's.
Note that a status
code of 200 will trigger a URL rewrite, which is what you want in SPA situations, e.g:
{{< code-toggle file="config/development/server">}} redirects from = "/myspa/**" to = "/myspa/" status = 200 force = false {{< /code-toggle >}}
Setting force=true
will make a redirect even if there is existing content in the path. Note that before Hugo 0.76 force
was the default behavior, but this is inline with how Netlify does it.
404 Server Error Page
{{< new-in "0.103.0" >}}
Hugo will, by default, render all 404 errors when running hugo server
with the 404.html
template. Note that if you have already added one or more redirects to your Server Config, you need to add the 404 redirect explicitly, e.g:
[[redirects]]
from = "/**"
to = "/404.html"
status = 404
Configure Title Case
Set titleCaseStyle
to specify the title style used by the title template function and the automatic section titles in Hugo. It defaults to AP Stylebook for title casing, but you can also set it to Chicago
or Go
(every word starts with a capital letter).
Configuration Environment Variables
- HUGO_NUMWORKERMULTIPLIER
- Can be set to increase or reduce the number of workers used in parallel processing in Hugo. If not set, the number of logical CPUs will be used.
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" permalinks: posts: /: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.
To set config params, prefix the name with HUGO_PARAMS_
{{% /note %}}
If you are using snake_cased variable names, the above will not work. Hugo determines the delimiter to use by the first character after HUGO
. This allows you to define environment variables on the form HUGOxPARAMSxAPI_KEY=abcdefgh
, using any allowed delimiter.
{{< todo >}} Test and document setting params via JSON env var. {{< /todo >}}
Ignore Content and Data Files when Rendering
To exclude specific files from the content
and data
directories when rendering your site, set ignoreFiles
to one or more regular expressions to match against the absolute file path.
To ignore files ending with .foo
or .boo
:
{{< code-toggle copy="false" >}} ignoreFiles = ['.foo$', '.boo$'] {{< /code-toggle >}}
To ignore a file using the absolute file path:
{{< code-toggle copy="false" >}} ignoreFiles = ['^/home/user/project/content/test.md$'] {{< /code-toggle >}}
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:
{{< code-toggle file="config" >}} [frontmatter] date = ["date", "publishDate", "lastmod"] lastmod = [":git", "lastmod", "date", "publishDate"] publishDate = ["publishDate", "date"] expiryDate = ["expiryDate"] {{< /code-toggle >}}
If you, as an example, have a non-standard date parameter in some of your content, you can override the setting for date
:
{{< code-toggle file="config" >}} [frontmatter] date = ["myDate", ":default"] {{< /code-toggle >}}
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:
{{< code-toggle file="config" >}} [frontmatter] lastmod = ["lastmod", ":fileModTime", ":default"] {{< /code-toggle >}}
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,
2018-02-22-mypage.md
will extract the date2018-02-22
. Also, ifslug
is not set,mypage
will be used as the value for.Slug
.
An example:
{{< code-toggle file="config" >}} [frontmatter] date = [":filename", ":default"] {{< /code-toggle >}}
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 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.
Configure Minify
Default configuration:
{{< code-toggle config="minify" />}}
Configure File Caches
Since Hugo 0.52 you can configure more than just the cacheDir
. This is the default configuration:
{{< code-toggle >}} [caches] [caches.getjson] dir = ":cacheDir/:project" maxAge = -1 [caches.getcsv] dir = ":cacheDir/:project" maxAge = -1 [caches.getresource] dir = ":cacheDir/:project" maxAge = -1 [caches.images] dir = ":resourceDir/_gen" maxAge = -1 [caches.assets] dir = ":resourceDir/_gen" maxAge = -1 [caches.modules] dir = ":cacheDir/modules" maxAge = -1 {{< /code-toggle >}}
You can override any of these cache settings in your own config.toml
.
The keywords explained
:cacheDir
- This is the value of the
cacheDir
config option if set (can also be set via OS env variableHUGO_CACHEDIR
). It will fall back to/opt/build/cache/hugo_cache/
on Netlify, or ahugo_cache
directory below the OS temp dir for the others. This means that if you run your builds on Netlify, all caches configured with:cacheDir
will be saved and restored on the next build. For other CI vendors, please read their documentation. For an CircleCI example, see this configuration. :project
- The base directory name of the current Hugo project. This means that, in its default setting, every project will have separated file caches, which means that when you do
hugo --gc
you will not touch files related to other Hugo projects running on the same PC. :resourceDir
- This is the value of the
resourceDir
config option. - maxAge
- This is the duration before a cache entry will be evicted, -1 means forever and 0 effectively turns that particular cache off. Uses Go's
time.Duration
, so valid values are"10s"
(10 seconds),"10m"
(10 minutes) and"10h"
(10 hours). - dir
- The absolute path to where the files for this cache will be stored. Allowed starting placeholders are
:cacheDir
and:resourceDir
(see above).