Modules Overview

This article shows how to install, uninstall and upgrade modules.

Install Modules

It’s quite simply to add a module into your site, just import the module path in configuration. Let’s take the back to top module as an example.

hugo.toml

1[module]
2[[module.import]]
3  path = 'github.com/razonyang/hb/modules/back-to-top'

hugo.yaml

1module:
2  import:
3  - path: github.com/razonyang/hb/modules/back-to-top

hugo.json

1{
2   "module": {
3      "import": [
4         {
5            "path": "github.com/razonyang/hb/modules/back-to-top"
6         }
7      ]
8   }
9}

You’ll need to restart the Hugo server to load the assets fully after installing modules.

Uninstall Modules

Remove or comment the modules to uninstall.

1# [[module.import]]
2# path = "github.com/razonyang/hb/modules/back-to-top"

Upgrade Modules

upgrade all modules recursive:

1hugo mod get -u ./...

update the latest version possible for a given module:

1hugo mod get -u github.com/razonyang/hb/modules/back-to-top

upgrade a specific version:

1hugo mod get -u github.com/razonyang/hb/modules/back-to-top@v0.2.0