mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
---
|
||||
title: Use Hugo Modules
|
||||
description: How to use Hugo Modules to build and manage your site.
|
||||
categories: [hugo modules]
|
||||
keywords: [modules,themes]
|
||||
menu:
|
||||
docs:
|
||||
parent: modules
|
||||
weight: 30
|
||||
weight: 30
|
||||
description: How to use Hugo Modules.
|
||||
categories: []
|
||||
keywords: []
|
||||
weight: 20
|
||||
aliases: [/themes/usage/,/themes/installing/,/installing-and-using-themes/]
|
||||
toc: true
|
||||
---
|
||||
|
||||
## Prerequisite
|
||||
|
||||
{{< gomodules-info >}}
|
||||
{{% include "/_common/gomodules-info.md" %}}
|
||||
|
||||
## Initialize a new module
|
||||
|
||||
@@ -33,15 +28,15 @@ 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>`
|
||||
1. Import the theme:
|
||||
|
||||
{{< code-toggle file=hugo >}}
|
||||
[module]
|
||||
[[module.imports]]
|
||||
path = "github.com/spf13/hyde"
|
||||
{{< /code-toggle >}}
|
||||
{{< code-toggle file=hugo >}}
|
||||
[module]
|
||||
[[module.imports]]
|
||||
path = "github.com/spf13/hyde"
|
||||
{{< /code-toggle >}}
|
||||
|
||||
## Update modules
|
||||
|
||||
Modules will be downloaded and added when you add them as imports to your configuration, see [Module Imports](/hugo-modules/configuration/#module-configuration-imports).
|
||||
Modules will be downloaded and added when you add them as imports to your configuration. See [configure modules](/configuration/module/#imports).
|
||||
|
||||
To update or manage versions, you can use `hugo mod get`.
|
||||
|
||||
@@ -83,7 +78,7 @@ 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 configuration [`replacements`](/hugo-modules/configuration/#module-configuration-top-level) option.
|
||||
Instead of modifying the `go.mod` files, you can also use the modules configuration [`replacements`](/configuration/module/#top-level-options) option.
|
||||
|
||||
## Print dependency graph
|
||||
|
||||
@@ -111,9 +106,9 @@ Also see the [CLI Doc](/commands/hugo_mod_graph/).
|
||||
|
||||
Note that:
|
||||
|
||||
* You can run `hugo mod vendor` on any level in the module tree.
|
||||
* Vendoring will not store modules stored in your `themes` directory.
|
||||
* 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.
|
||||
- You can run `hugo mod vendor` on any level in the module tree.
|
||||
- Vendoring will not store modules stored in your `themes` directory.
|
||||
- Most commands accept a `--ignoreVendorPaths` flag, which will then not use the vendored modules in `_vendor` for the module paths matching the given [glob](g) pattern.
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_vendor/).
|
||||
|
||||
@@ -127,7 +122,7 @@ Also see the [CLI Doc](/commands/hugo_mod_clean/).
|
||||
|
||||
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).
|
||||
Note that you can also configure the `modules` cache with a `maxAge`. See [configure caches](/configuration/caches/).
|
||||
|
||||
Also see the [CLI Doc](/commands/hugo_mod_clean/).
|
||||
|
||||
@@ -137,7 +132,7 @@ Workspace support was added in [Go 1.18](https://go.dev/blog/get-familiar-with-w
|
||||
|
||||
A common use case for a workspace is to simplify local development of a site with its theme modules.
|
||||
|
||||
A workspace can be configured in a `*.work` file and activated with the [module.workspace](/hugo-modules/configuration/) setting, which for this use is commonly controlled via the `HUGO_MODULE_WORKSPACE` OS environment variable.
|
||||
A workspace can be configured in a `*.work` file and activated with the [module.workspace](/configuration/module/) setting, which for this use is commonly controlled via the `HUGO_MODULE_WORKSPACE` OS environment variable.
|
||||
|
||||
See the [hugo.work](https://github.com/gohugoio/hugo/blob/master/docs/hugo.work) file in the Hugo Docs repo for an example:
|
||||
|
||||
|
Reference in New Issue
Block a user