To divide a hugo page into modules resp. move a part of it into a module, three steps are needed:
- make site a module
- make part a module
- import part via site config.toml
for 1. + 2. : to convert anything into a go module, a go.mod file needs to be created with:
hugo mod init github.com/<owner>/<repo>
for 3. : Import module in config.toml:
[module]
[[module.imports]]
path = 'github.com/spf13/hyde'
see https://gohugo.io/hugo-modules/use-modules/#use-a-module-for-a-theme
the default is to get the module via github, it is stored in GOPATH or ~/go
hugo mod get -u
gets the latest version/tag (eg. v0.1.0) from github and updates the go.sum file.
To develop a module, use replacements:
[module]
replacements = 'github.com/bkleinen/minimal-site-module -> ../../minimal-module'
The module can even be in a git submodule, see the project-archive integration in showtime-website:
https://github.com/htw-imi-showtime/showtime-website
The documentation shows an example for site mounts, not for module mounts. To mount paths in a module to a different target, use:
[[module.imports]]
path = 'github.com/bkleinen/minimal-site-module'
[[module.imports.mounts]]
source = "other_path_name"
target = "content/other"
[[module.imports.mounts]]
source = "content"
target = "content"
Check all mounts with
hugo config mounts
go clean -modcache