Modules Overview

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

Initialize Modules and Themes

To use Hugo modules, you need to initialize your modules and themes first.

1hugo mod init

Install Modules

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


3    path = ''


2  imports:
3  - path:


2   "module": {
3      "imports": [
4         {
5            "path": ""
6         }
7      ]
8   }

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

Uninstall Modules

To uninstall modules, you need to remove or comment the modules from the configuration file, and then execute hugo mod tidy.

2# path = ""
1hugo mod tidy

Upgrade Modules

Upgrade all modules recursive:

1hugo mod get -u ./...

Update the latest version1 possible for a given module:

1hugo mod get -u

Upgrade a specific version1:

1hugo mod get -u[email protected]

Tidy Modules

The following command remove unused modules from go.mod and go.sum.

1hugo mod tidy

Clean Modules Cache

Delete the Hugo Module cache for the current site:

1hugo mod clean

You may be interested in which modules the site imports and their dependencies.

1hugo mod graph
1hugo mod graph | grep blog

  1. The version can be any releases, tags, branches, or even commits. ↩︎ ↩︎