mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Merge commit '00c4484c7092181729f6f470805bc7d72e8ad17b'
This commit is contained in:
@@ -24,7 +24,7 @@ You can combine modules in any combination you like, and even mount directories
|
||||
Hugo Modules are powered by Go Modules. For more information about Go Modules, see:
|
||||
|
||||
- [https://github.com/golang/go/wiki/Modules](https://github.com/golang/go/wiki/Modules)
|
||||
- [https://blog.golang.org/using-go-modules](https://blog.golang.org/using-go-modules)
|
||||
- [https://go.dev/blog/using-go-modules](https://go.dev/blog/using-go-modules)
|
||||
|
||||
This is all very much brand new and there are only a few example projects around:
|
||||
|
||||
|
@@ -26,12 +26,11 @@ replacements = ""
|
||||
workspace = ""
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
noVendor {{< new-in "0.75.0" >}}
|
||||
noVendor
|
||||
: A optional Glob pattern matching module paths to skip when vendoring, e.g. "github.com/**"
|
||||
|
||||
vendorClosest {{< new-in "0.81.0" >}}
|
||||
: When enabled, we will pick the vendored module closest to the module using it. The default behaviour 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.
|
||||
vendorClosest
|
||||
: 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.
|
||||
|
||||
proxy
|
||||
: Defines the proxy server to use to download remote modules. Default is `direct`, which means "git clone" and similar.
|
||||
@@ -42,15 +41,15 @@ noProxy
|
||||
private
|
||||
: Comma separated glob list matching paths that should be treated as private.
|
||||
|
||||
workspace {{< new-in "0.83.0" >}}
|
||||
workspace
|
||||
: 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+.
|
||||
|
||||
replacements {{< new-in "0.77.0" >}}
|
||||
replacements
|
||||
: A comma separated (or a slice) list of module path to directory replacement mapping, e.g. `github.com/bep/my-theme -> ../..,github.com/bep/shortcodes -> /some/path`. This is mostly useful for temporary locally development of a module, and then it makes sense to set it as an OS environment variable, e.g: `env HUGO_MODULE_REPLACEMENTS="github.com/bep/my-theme -> ../.."`. Any relative path is relate to [themesDir](https://gohugo.io/getting-started/configuration/#all-configuration-settings), and 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:
|
||||
|
||||
```
|
||||
```txt
|
||||
env HUGO_MODULE_PROXY=https://proxy.example.org hugo
|
||||
```
|
||||
|
||||
@@ -99,13 +98,13 @@ path
|
||||
ignoreConfig
|
||||
: If enabled, any module configuration file, e.g. `config.toml`, will not be loaded. Note that this will also stop the loading of any transitive module dependencies.
|
||||
|
||||
ignoreImports {{< new-in "0.80.0" >}}
|
||||
ignoreImports
|
||||
: If enabled, module imports will not be followed.
|
||||
|
||||
disable
|
||||
: Set to `true` to disable the module while keeping any version info in the `go.*` files.
|
||||
|
||||
noMounts {{< new-in "0.84.2" >}}
|
||||
noMounts
|
||||
: Do not mount any folder in this import.
|
||||
|
||||
noVendor
|
||||
@@ -113,7 +112,6 @@ noVendor
|
||||
|
||||
{{< gomodules-info >}}
|
||||
|
||||
|
||||
## Module Config: mounts
|
||||
|
||||
{{% note %}}
|
||||
@@ -160,14 +158,11 @@ lang
|
||||
: The language code, e.g. "en". Only relevant for `content` mounts, and `static` mounts when in multihost mode.
|
||||
|
||||
includeFiles (string or slice)
|
||||
: One or more [glob](https://github.com/gobwas/glob) patterns matching files or directories to include. If `excludeFiles` is not set, the files matching `includeFiles` will be the files mounted.
|
||||
: One or more [glob](https://github.com/gobwas/glob) patterns matching files or directories to include. If `excludeFiles` is not set, the files matching `includeFiles` will be the files mounted.
|
||||
|
||||
The glob patterns are matched to the filenames 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.
|
||||
|
||||
{{< new-in "0.89.0" >}}
|
||||
|
||||
excludeFiles (string or slice)
|
||||
: One or more glob patterns matching files to exclude.
|
||||
|
||||
|
@@ -25,7 +25,6 @@ Since Hugo `0.42` a project can configure a theme as a composite of as many them
|
||||
theme = ["my-shortcodes", "base-theme", "hyde"]
|
||||
{{< /code-toggle >}}
|
||||
|
||||
|
||||
You can even nest this, and have the theme component itself include theme components in its own `config.toml` (theme inheritance).[^1]
|
||||
|
||||
The theme definition example above in `config.toml` creates a theme with 3 theme components with precedence from left to right.
|
||||
@@ -34,7 +33,7 @@ For any given file, data entry, etc., Hugo will look first in the project and th
|
||||
|
||||
Hugo uses two different algorithms to merge the filesystems, depending on the file type:
|
||||
|
||||
* For `i18n` and `data` files, Hugo merges deeply using the translation id and data key inside the files.
|
||||
* For `i18n` and `data` files, Hugo merges deeply using the translation ID and data key inside the files.
|
||||
* For `static`, `layouts` (templates), and `archetypes` files, these are merged on file level. So the left-most file will be chosen.
|
||||
|
||||
The name used in the `theme` definition above must match a folder in `/your-site/themes`, e.g. `/your-site/themes/my-shortcodes`. There are plans to improve on this and get a URL scheme so this can be resolved automatically.
|
||||
@@ -47,8 +46,4 @@ Also note that a component that is part of a theme can have its own configuratio
|
||||
|
||||
The same rules apply here: The left-most param/menu etc. with the same ID will win. There are some hidden and experimental namespace support in the above, which we will work to improve in the future, but theme authors are encouraged to create their own namespaces to avoid naming conflicts.
|
||||
|
||||
|
||||
[^1]: For themes hosted on the [Hugo Themes Showcase](https://themes.gohugo.io/) components need to be added as git submodules that point to the directory `exampleSite/themes`
|
||||
|
||||
|
||||
|
||||
[^1]: For themes hosted on the [Hugo Themes Showcase](https://themes.gohugo.io/) components need to be added as git submodules that point to the directory `exampleSite/themes`
|
||||
|
@@ -20,8 +20,6 @@ toc: true
|
||||
|
||||
{{< gomodules-info >}}
|
||||
|
||||
|
||||
|
||||
## Initialize a New Module
|
||||
|
||||
Use `hugo mod init` to initialize a new Hugo Module. If it fails to guess the module path, you must provide it as an argument, e.g.:
|
||||
@@ -33,6 +31,7 @@ hugo mod init github.com/gohugoio/myShortcodes
|
||||
Also see the [CLI Doc](/commands/hugo_mod_init/).
|
||||
|
||||
## Use a Module for a Theme
|
||||
|
||||
The easiest way to use a Module for a theme is to import it in the config.
|
||||
|
||||
1. Initialize the hugo module system: `hugo mod init github.com/<your_user>/<your_project>`
|
||||
@@ -60,8 +59,6 @@ hugo mod get -u
|
||||
|
||||
### Update All Modules Recursively
|
||||
|
||||
{{< new-in "0.65.0" >}}
|
||||
|
||||
```bash
|
||||
hugo mod get -u ./...
|
||||
```
|
||||
@@ -71,6 +68,7 @@ hugo mod get -u ./...
|
||||
```bash
|
||||
hugo mod get -u github.com/gohugoio/myShortcodes
|
||||
```
|
||||
|
||||
### Get a Specific Version
|
||||
|
||||
```bash
|
||||
@@ -89,16 +87,15 @@ replace github.com/bep/hugotestmods/mypartials => /Users/bep/hugotestmods/mypart
|
||||
|
||||
If you have the `hugo server` running, the configuration will be reloaded and `/Users/bep/hugotestmods/mypartials` put on the watch list.
|
||||
|
||||
Note that since v.0.77.0 you can use modules config [`replacements`](https://gohugo.io/hugo-modules/configuration/#module-config-top-level) option. {{< new-in "0.77.0" >}}
|
||||
Instead of modifying the `go.mod` files, you can also use the modules config [`replacements`](https://gohugo.io/hugo-modules/configuration/#module-config-top-level) option.
|
||||
|
||||
## Print Dependency Graph
|
||||
|
||||
|
||||
Use `hugo mod graph` from the relevant module directory and it will print the dependency graph, including vendoring, module replacement or disabled status.
|
||||
|
||||
E.g.:
|
||||
|
||||
```
|
||||
```txt
|
||||
hugo mod graph
|
||||
|
||||
github.com/bep/my-modular-site github.com/bep/hugotestmods/mymounts@v1.2.0
|
||||
@@ -121,11 +118,10 @@ Note that:
|
||||
|
||||
* You can run `hugo mod vendor` on any level in the module tree.
|
||||
* Vendoring will not store modules stored in your `themes` folder.
|
||||
* Most commands accept a `--ignoreVendorPaths` flag, which will then not use the vendored modules in `_vendor` for the module paths matching the [Glob](https://github.com/gobwas/glob) pattern given. Note that before Hugo 0.75 this flag was named `--ignoreVendor` and was a "all or nothing". {{< new-in "0.75.0" >}}
|
||||
* Most commands accept a `--ignoreVendorPaths` flag, which will then not use the vendored modules in `_vendor` for the module paths matching the [Glob](https://github.com/gobwas/glob) pattern given.
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_vendor/).
|
||||
|
||||
|
||||
## Tidy go.mod, go.sum
|
||||
|
||||
Run `hugo mod tidy` to remove unused entries in `go.mod` and `go.sum`.
|
||||
@@ -138,6 +134,4 @@ Run `hugo mod clean` to delete the entire modules cache.
|
||||
|
||||
Note that you can also configure the `modules` cache with a `maxAge`, see [File Caches](/getting-started/configuration/#configure-file-caches).
|
||||
|
||||
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_clean/).
|
||||
|
Reference in New Issue
Block a user