mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Merge commit '87de22d7464e239c775fbd48ebce1665d5b1e80d'
This commit is contained in:
@@ -6,8 +6,8 @@ keywords: [install, themes, source, organization, directories,usage,modules]
|
||||
menu:
|
||||
docs:
|
||||
parent: modules
|
||||
weight: 20
|
||||
weight: 20
|
||||
weight: 30
|
||||
weight: 30
|
||||
aliases: [/themes/usage/,/themes/installing/,/installing-and-using-themes/]
|
||||
toc: true
|
||||
---
|
||||
@@ -16,7 +16,7 @@ toc: true
|
||||
|
||||
{{< gomodules-info >}}
|
||||
|
||||
## Initialize a New Module
|
||||
## 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.:
|
||||
|
||||
@@ -26,9 +26,9 @@ hugo mod init github.com/gohugoio/myShortcodes
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_init/).
|
||||
|
||||
## Use a Module for a Theme
|
||||
## Use a module for a theme
|
||||
|
||||
The easiest way to use a Module for a theme is to import it in the config.
|
||||
The easiest way to use a Module for a theme is to import it in the configuration.
|
||||
|
||||
1. Initialize the hugo module system: `hugo mod init github.com/<your_user>/<your_project>`
|
||||
2. Import the theme:
|
||||
@@ -39,33 +39,33 @@ The easiest way to use a Module for a theme is to import it in the config.
|
||||
path = "github.com/spf13/hyde"
|
||||
{{< /code-toggle >}}
|
||||
|
||||
## Update Modules
|
||||
## Update modules
|
||||
|
||||
Modules will be downloaded and added when you add them as imports to your configuration, see [Module Imports](/hugo-modules/configuration/#module-config-imports).
|
||||
Modules will be downloaded and added when you add them as imports to your configuration, see [Module Imports](/hugo-modules/configuration/#module-configuration-imports).
|
||||
|
||||
To update or manage versions, you can use `hugo mod get`.
|
||||
|
||||
Some examples:
|
||||
|
||||
### Update All Modules
|
||||
### Update all modules
|
||||
|
||||
```bash
|
||||
hugo mod get -u
|
||||
```
|
||||
|
||||
### Update All Modules Recursively
|
||||
### Update all modules recursively
|
||||
|
||||
```bash
|
||||
hugo mod get -u ./...
|
||||
```
|
||||
|
||||
### Update One Module
|
||||
### Update one module
|
||||
|
||||
```bash
|
||||
hugo mod get -u github.com/gohugoio/myShortcodes
|
||||
```
|
||||
|
||||
### Get a Specific Version
|
||||
### Get a specific version
|
||||
|
||||
```bash
|
||||
hugo mod get github.com/gohugoio/myShortcodes@v1.0.7
|
||||
@@ -83,9 +83,9 @@ 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.
|
||||
|
||||
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.
|
||||
Instead of modifying the `go.mod` files, you can also use the modules configuration [`replacements`](/hugo-modules/configuration/#module-configuration-top-level) option.
|
||||
|
||||
## Print Dependency Graph
|
||||
## 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.
|
||||
|
||||
@@ -106,7 +106,7 @@ github.com/bep/my-modular-site in-themesdir
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_graph/).
|
||||
|
||||
## Vendor Your Modules
|
||||
## Vendor your modules
|
||||
|
||||
`hugo mod vendor` will write all the module dependencies to a `_vendor` folder, which will then be used for all subsequent builds.
|
||||
|
||||
@@ -124,7 +124,7 @@ Run `hugo mod tidy` to remove unused entries in `go.mod` and `go.sum`.
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_clean/).
|
||||
|
||||
## Clean Module Cache
|
||||
## Clean module cache
|
||||
|
||||
Run `hugo mod clean` to delete the entire modules cache.
|
||||
|
||||
@@ -132,7 +132,7 @@ Note that you can also configure the `modules` cache with a `maxAge`, see [File
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_clean/).
|
||||
|
||||
## Module Workspaces
|
||||
## Module workspaces
|
||||
|
||||
{{< new-in "0.109.0" >}}
|
||||
|
||||
@@ -144,7 +144,7 @@ A workspace can be configured in a `*.work` file and activated with the [module.
|
||||
|
||||
See the [hugo.work](https://github.com/gohugoio/hugo/blob/master/hugo.work) file in the Hugo Docs repo for an example:
|
||||
|
||||
```
|
||||
```text
|
||||
go 1.19
|
||||
|
||||
use .
|
||||
@@ -155,7 +155,7 @@ Using the `use` directive, list all the modules you want to work on, pointing to
|
||||
|
||||
With that you can start the Hugo server with that workspace enabled:
|
||||
|
||||
```
|
||||
```bash
|
||||
HUGO_MODULE_WORKSPACE=hugo.work hugo server --ignoreVendorPaths "**"
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user