Configure modules
Top-level options
This is the default configuration:
module:
noProxy: none
noVendor: ""
private: '*.*'
proxy: direct
vendorClosest: false
workspace: "off"
[module]
noProxy = 'none'
noVendor = ''
private = '*.*'
proxy = 'direct'
vendorClosest = false
workspace = 'off'
{
"module": {
"noProxy": "none",
"noVendor": "",
"private": "*.*",
"proxy": "direct",
"vendorClosest": false,
"workspace": "off"
}
}
- auth
- New in v0.144.0
- (
string
) ConfiguresGOAUTH
when running the Go command for module operations. This is a semicolon-separated list of authentication commands for go-import and HTTPS module mirror interactions. This is useful for private repositories. Seego help goauth
for more information. - noProxy
- (
string
) A comma-separated list of glob patterns matching paths that should not use the configured proxy server. - noVendor
- (
string
) A glob pattern matching module paths to skip when vendoring. - private
- (
string
) A comma-separated list of glob patterns matching paths that should be treated as private. - proxy
- (
string
) The proxy server to use to download remote modules. Default isdirect
, which meansgit clone
and similar. - replacements
- (
string
) Primarily useful for local module development, a comma-separated list of mappings from module paths to directories. Paths may be absolute or relative to thethemesDir
.module: replacements: github.com/bep/my-theme -> ../..,github.com/bep/shortcodes -> /some/path
[module] replacements = 'github.com/bep/my-theme -> ../..,github.com/bep/shortcodes -> /some/path'
{ "module": { "replacements": "github.com/bep/my-theme -\u003e ../..,github.com/bep/shortcodes -\u003e /some/path" } }
- vendorClosest
- (
bool
) Whether to pick the vendored module closest to the module using it. The default behavior is to pick the first. Note that there can still be only one dependency of a given module path, so once it is in use it cannot be redefined. Default isfalse
. - workspace
- (
string
) The Go workspace file to use, either as an absolute path or a path relative to the current working directory. Enabling this activates Go workspace mode and requires Go 1.18 or later. The default isoff
.
You may also use environment variables to set any of the above. For example:
export HUGO_MODULE_PROXY="https://proxy.example.org"
export HUGO_MODULE_REPLACEMENTS="github.com/bep/my-theme -> ../.."
export HUGO_MODULE_WORKSPACE="/my/hugo.work"
Go Modules
Most of the commands for Hugo Modules require a newer version (>= 1.18) of Go installed (see https://golang.org/dl/) and the relevant VCS client (e.g. Git, see https://git-scm.com/downloads/ ). If you have an “older” site running on Netlify, you may have to set GO_VERSION to 1.19 or newer in your Environment settings.
For more information about Go Modules, see:
Hugo version
You can specify a required Hugo version for your module in the module
section. Users will then receive a warning if their Hugo version is incompatible.
This is the default configuration:
module:
hugoVersion:
extended: false
max: ""
min: ""
[module]
[module.hugoVersion]
extended = false
max = ''
min = ''
{
"module": {
"hugoVersion": {
"extended": false,
"max": "",
"min": ""
}
}
}
You can omit any of the settings above.
- extended
- (
bool
) Whether the extended edition of Hugo is required, satisfied by installing either the extended or extended/deploy edition. - max
- (
string
) The maximum Hugo version supported, for example0.143.0
. - min
- (
string
) The minimum Hugo version supported, for example0.123.0
.
Imports
module:
imports:
- disable: false
ignoreConfig: false
ignoreImports: false
path: github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v
- path: my-shortcodes
[module]
[[module.imports]]
disable = false
ignoreConfig = false
ignoreImports = false
path = 'github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v'
[[module.imports]]
path = 'my-shortcodes'
{
"module": {
"imports": [
{
"disable": false,
"ignoreConfig": false,
"ignoreImports": false,
"path": "github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v"
},
{
"path": "my-shortcodes"
}
]
}
}
- disable
- (
bool
) Whether to disable the module but keep version information in thego.*
files. Default isfalse
. - ignoreConfig
- (
bool
) Whether to ignore module configuration files, for example,hugo.toml
. This will also prevent loading of any transitive module dependencies. Default isfalse
. - ignoreImports
- (
bool
) Whether to ignore module imports. Default isfalse
. - noMounts
- (
bool
) Whether to disable directory mounting for this import. Default isfalse
. - noVendor
- (
bool
) Whether to disable vendoring for this import. This setting is restricted to the main project. Default isfalse
. - path
- (
string
) The module path, either a valid Go module path (e.g.,github.com/gohugoio/myShortcodes
) or the directory name if stored in thethemesDir
.
Go Modules
Most of the commands for Hugo Modules require a newer version (>= 1.18) of Go installed (see https://golang.org/dl/) and the relevant VCS client (e.g. Git, see https://git-scm.com/downloads/ ). If you have an “older” site running on Netlify, you may have to set GO_VERSION to 1.19 or newer in your Environment settings.
For more information about Go Modules, see:
Mounts
Before Hugo v0.56.0, custom component paths could only be configured by setting archetypeDir
, assetDir
, contentDir
, dataDir
, i18nDir
, layoutDi
, or staticDir
in the site configuration. Module mounts offer greater flexibility than these legacy settings, but
you cannot use both.
If you use module mounts do not use the legacy settings.
Default mounts
Adding a new mount to a target root will cause the existing default mount for that root to be ignored. If you still need the default mount, you must explicitly add it along with the new mount.
The are the default mounts:
module:
mounts:
- disableWatch: false
excludeFiles: null
includeFiles: null
lang: ""
source: content
target: content
- disableWatch: false
excludeFiles: null
includeFiles: null
lang: ""
source: data
target: data
- disableWatch: false
excludeFiles: null
includeFiles: null
lang: ""
source: layouts
target: layouts
- disableWatch: false
excludeFiles: null
includeFiles: null
lang: ""
source: i18n
target: i18n
- disableWatch: false
excludeFiles: null
includeFiles: null
lang: ""
source: archetypes
target: archetypes
- disableWatch: false
excludeFiles: null
includeFiles: null
lang: ""
source: assets
target: assets
- disableWatch: false
excludeFiles: null
includeFiles: null
lang: ""
source: static
target: static
[module]
[[module.mounts]]
disableWatch = false
lang = ''
source = 'content'
target = 'content'
[[module.mounts]]
disableWatch = false
lang = ''
source = 'data'
target = 'data'
[[module.mounts]]
disableWatch = false
lang = ''
source = 'layouts'
target = 'layouts'
[[module.mounts]]
disableWatch = false
lang = ''
source = 'i18n'
target = 'i18n'
[[module.mounts]]
disableWatch = false
lang = ''
source = 'archetypes'
target = 'archetypes'
[[module.mounts]]
disableWatch = false
lang = ''
source = 'assets'
target = 'assets'
[[module.mounts]]
disableWatch = false
lang = ''
source = 'static'
target = 'static'
{
"module": {
"mounts": [
{
"disableWatch": false,
"excludeFiles": null,
"includeFiles": null,
"lang": "",
"source": "content",
"target": "content"
},
{
"disableWatch": false,
"excludeFiles": null,
"includeFiles": null,
"lang": "",
"source": "data",
"target": "data"
},
{
"disableWatch": false,
"excludeFiles": null,
"includeFiles": null,
"lang": "",
"source": "layouts",
"target": "layouts"
},
{
"disableWatch": false,
"excludeFiles": null,
"includeFiles": null,
"lang": "",
"source": "i18n",
"target": "i18n"
},
{
"disableWatch": false,
"excludeFiles": null,
"includeFiles": null,
"lang": "",
"source": "archetypes",
"target": "archetypes"
},
{
"disableWatch": false,
"excludeFiles": null,
"includeFiles": null,
"lang": "",
"source": "assets",
"target": "assets"
},
{
"disableWatch": false,
"excludeFiles": null,
"includeFiles": null,
"lang": "",
"source": "static",
"target": "static"
}
]
}
}
- source
- (
string
) The source directory of the mount. For the main project, this can be either project-relative or absolute. For other modules it must be project-relative. - target
- (
string
) Where the mount will reside within Hugo’s virtual file system. It must begin with one of Hugo’s component directories:archetypes
,assets
,content
,data
,i18n
,layouts
, orstatic
. For example,content/blog
. - disableWatch
- New in v0.128.0
- (
bool
) Whether to disable watching in watch mode for this mount. Default isfalse
. - lang
- (
string
) The language code, e.g. “en”. Relevant forcontent
mounts, andstatic
mounts when in multihost mode. - includeFiles
- (
string
or[]string
) One or more glob patterns matching files or directories to include. IfexcludeFiles
is not set, the files matchingincludeFiles
will be the files mounted.The glob patterns are matched against file names relative to the source root. Use Unix-style forward slashes (
/
), even on Windows. A single forward slash (/
) matches the mount root, and double asterisks (**
) act as a recursive wildcard, matching all directories and files beneath a given point (e.g.,/posts/**.jpg
). The search is case-insensitive. - excludeFiles
- (
string
or[]string
) One or more glob patterns matching files to exclude.
Example
module:
mounts:
- excludeFiles: docs/*
source: content
target: content
- source: node_modules
target: assets
- source: assets
target: assets
[module]
[[module.mounts]]
excludeFiles = 'docs/*'
source = 'content'
target = 'content'
[[module.mounts]]
source = 'node_modules'
target = 'assets'
[[module.mounts]]
source = 'assets'
target = 'assets'
{
"module": {
"mounts": [
{
"excludeFiles": "docs/*",
"source": "content",
"target": "content"
},
{
"source": "node_modules",
"target": "assets"
},
{
"source": "assets",
"target": "assets"
}
]
}
}