fcc3ed651 Remove some expired new-in a9c5981f5 Fix cascade example 82bb250fa Add some lines about permalinks tokens in front matter 328fe564e Remove some outdated new-in fb140b153 Hide showcase menu entry 42d9d1c79 Update image formats from which EXIF data can be extracted 09ad56b6e netlify: Hugo 0.130.0 1d503f846 Merge branch 'tempv0.130.0' e2458074d math: Add trigonometric functions and some angle helper functions 392afc8f9 Disable the showcase section for now 0300750f2 Improve example of image render hook 60a9306af Improve description of the .Site.RegularPages method 8d759175d Fix typos 55daa4554 Update XxHash.md 397c81cb7 Add namespace for hash functions 70fe8d2f0 netlify: Bump Hugo 0.129.0 5a9771aff Merge branch 'tempv0.129.0' f9146575b Fix typo e6e1fea49 Fix typo in Hugo docs | functions | partial 732d10ec4 source: Expose GitInfo Body 34c97e639 netlify: Hugo 0.128.2 3270587e9 Fix typo 727c5396e netlify: Hugo 0.128.1 80b6ae99c Update GitHub Pages workflow file example 027134102 Update GitHub Pages workflow file example 2600a8a2e Miscellaneous edits 3fdd5819b Update Build.md 7764005c3 Improve example of render hook directory structure 5e3941d82 Fix typos 748bf065f Restructure templates section fafbf6566 Update Defer.md 012162e0d Document changes to template functions in v0.128.0 0990ce35b quick-reference: Update emojis 6677a30ef Update Goldmark configuration documentation 4449d530d Document new pagination config 0af8be439 Update Defer.md 56348196d netlify: Hugo 0.128.0 d67b6d82e Update content/en/functions/templates/Defer.md 23d996b3d Update content/en/functions/templates/Defer.md 7f7fb2f27 Document templates.Defer 5ada1e9d5 Fix docs merge (remove shortcode) d27ee6156 Merge branch 'tempv0.128.0' 5d7317c84 Fix typo 7c18ee546 Update theme 83bfea63b Update theme b274b3238 Merge commit '8b9803425e63e1b1801f8d5d676e96368d706722' ff34a035a deploy: Add stripIndexHtml target option d9e964bdb markup/goldmark: Add the Hugo Goldmark Extras "delete" extension ac5bd16d2 deps: Upgrade github.com/alecthomas/chroma v2.13.0 => v2.14.0 25377171b config: Remove extraneous BuildConfig setting 0d2044f6d docs: Regen docshelper a2548dac9 markup/goldmark: Support extras extension 9d0c86ee8 commands: Add gen chromastyles --lineNumbersTableStyle flag git-subtree-dir: docs git-subtree-split: fcc3ed651a1b6431303c2f88f20fa38531c52b3d
6.3 KiB
title | description | categories | keywords | menu | weight | toc | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Configure Hugo modules | This page describes the configuration options for a module. |
|
|
|
20 | true |
Module configuration: top level
{{< code-toggle file=hugo >}} [module] noProxy = 'none' noVendor = '' private = '.' proxy = 'direct' replacements = '' vendorClosest = false workspace = 'off' {{< /code-toggle >}}
- noProxy
- (
string
) Comma separated glob list matching paths that should not use the proxy configured above. - noVendor
- (
string
) A optional Glob pattern matching module paths to skip when vendoring, e.g. "github.com/**" - private
- (
string
) Comma separated glob list matching paths that should be treated as private. - proxy
- (
string
) Defines the proxy server to use to download remote modules. Default isdirect
, which means "git clone" and similar. - vendorClosest
- (
bool
) When enabled, we will 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 workspace file to use. This enables Go workspace mode. Note that this can also be set via OS env, e.g.export HUGO_MODULE_WORKSPACE=/my/hugo.work
This only works with Go 1.18+. In Hugov0.109.0
we changed the default tooff
and we now resolve any relative work file names relative to the working directory. - replacements
- (
string
) A comma-separated list of mappings from module paths to directories, e.g.github.com/bep/my-theme -> ../..,github.com/bep/shortcodes -> /some/path
. This is mostly useful for temporary local development of a module, in which case you might want to save it as an environment variable, e.g:env HUGO_MODULE_REPLACEMENTS="github.com/bep/my-theme -> ../.."
. Relative paths are relative to themesDir. Absolute paths are allowed.
Note that the above terms maps directly to their counterparts in Go Modules. Some of these setting may be natural to set as OS environment variables. To set the proxy server to use, as an example:
env HUGO_MODULE_PROXY=https://proxy.example.org hugo
{{< gomodules-info >}}
Module configuration: hugoVersion
If your module requires a particular version of Hugo to work, you can indicate that in the module
section and the user will be warned if using a too old/new version.
{{< code-toggle file=hugo >}} [module] [module.hugoVersion] min = "" max = "" extended = false
{{< /code-toggle >}}
Any of the above can be omitted.
- min
- (
string
) The minimum Hugo version supported, e.g.0.55.0
- max
- (
string
) The maximum Hugo version supported, e.g.0.55.0
- extended
- (
bool
) Whether the extended version of Hugo is required.
Module configuration: imports
{{< code-toggle file=hugo >}} [module] module.imports path = "github.com/gohugoio/hugoTestModules1_linux/modh1_2_1v" ignoreConfig = false ignoreImports = false disable = false module.imports path = "my-shortcodes" {{< /code-toggle >}}
- path
- Can be either a valid Go Module module path, e.g.
github.com/gohugoio/myShortcodes
, or the directory name for the module as stored in your themes folder. - ignoreConfig
- If enabled, any module configuration file, e.g.
hugo.toml
, will not be loaded. Note that this will also stop the loading of any transitive module dependencies. - ignoreImports
- If enabled, module imports will not be followed.
- disable
- Set to
true
to disable the module while keeping any version info in thego.*
files. - noMounts
- Do not mount any folder in this import.
- noVendor
- Never vendor this import (only allowed in main project).
{{< gomodules-info >}}
Module configuration: mounts
{{% note %}}
When the mounts
configuration was introduced in Hugo 0.56.0, we were careful to preserve the existing contentDir
, staticDir
, and similar configuration to make sure all existing sites just continued to work. But you should not have both: if you add a mounts
section you should remove the old contentDir
, staticDir
, etc. settings.
{{% /note %}}
{{% note %}} When you add a mount, the default mount for the concerned target root is ignored: be sure to explicitly add it. {{% /note %}}
Default mounts
{{< code-toggle file=hugo >}} [module] module.mounts source="content" target="content" module.mounts source="static" target="static" module.mounts source="layouts" target="layouts" module.mounts source="data" target="data" module.mounts source="assets" target="assets" module.mounts source="i18n" target="i18n" module.mounts source="archetypes" target="archetypes" {{< /code-toggle >}}
- 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 it should be mounted into Hugo's virtual filesystem. It must start with one of Hugo's component folders:static
,content
,layouts
,data
,assets
,i18n
, orarchetypes
. E.g.content/blog
. - disableWatch
- {{< new-in 0.128.0 >}}
- (
bool
) Whether to disable watching in watch mode for this mount. Default isfalse
. - lang
- (
string
) The language code, e.g. "en". Only relevant forcontent
mounts, andstatic
mounts when in multihost mode. - includeFiles
- (
string
orstring slice
) 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 to the file names starting from the source
root, they should have Unix styled slashes even on Windows, /
matches the mount root and **
can be used as a super-asterisk to match recursively down all directories, e.g /posts/**.jpg
.
The search is case-insensitive.
- excludeFiles
- (
string
orstring slice
) One or more glob patterns matching files to exclude.
Example
{{< code-toggle file=hugo >}} [module] module.mounts source="content" target="content" excludeFiles="docs/*" module.mounts source="node_modules" target="assets" module.mounts source="assets" target="assets" {{< /code-toggle >}}