How to Use Hugo Modules

You’ll need to make some minor preparations before using the Hugo modules.

Install Go Binary

See download and install Go for details.

Initialize Module

Firstly, we need to initialize the module for your site or theme via hugo mod init MODULE_PATH.

The MODULE_PATH is the identifier of your theme or site, which is usually the repository URL, for example,

1hugo mod init example.com/user/repo

Import Modules

And then import the modules your want.

hugo.yaml

1module:
2  imports:
3  - path: github.com/hugomods/icons/vendors/bootstrap
4  - path: github.com/hugomods/images
5  - path: github.com/hugomods/bootstrap
6  - path: github.com/hugomods/katex

hugo.toml

1[module]
2[[module.imports]]
3    path = 'github.com/hugomods/icons/vendors/bootstrap'
4[[module.imports]]
5    path = 'github.com/hugomods/images'
6[[module.imports]]
7    path = 'github.com/hugomods/bootstrap'
8[[module.imports]]
9    path = 'github.com/hugomods/katex'

hugo.json

 1{
 2   "module": {
 3      "imports": [
 4         {
 5            "path": "github.com/hugomods/icons/vendors/bootstrap"
 6         },
 7         {
 8            "path": "github.com/hugomods/images"
 9         },
10         {
11            "path": "github.com/hugomods/bootstrap"
12         },
13         {
14            "path": "github.com/hugomods/katex"
15         }
16      ]
17   }
18}