× Search About Posts Code Music Links
Blank Try
experiment
lots
learn
more

Modules

Updated on
Last site update: 8 May 2024

To add something to a theme using Hugo modules you need to:

  1. Make your site a module (this process just adds a couple of files: go.mod and go.sum) using hugo mod init see gendoc.
  2. Add some code, like that below, to your config file.

Next you can either:

  1. Start Hugo server and see the content pulled from elsewhere
  2. Build the site using hugo and pull the content into the build site.
  3. Upload the site
1[module]
2
3[[module.imports]]
4    path = "github.com/craftsmandigital/markdown-content-repo"
5    disabled = false
6
7[[module.imports.mounts]]
8    source = "testing-hugo-modules"
9    target = "content/new-stuff"

Update

1hugo mod get -u github.com/twbs/icons

Fail

Trying to get some images from Mega.nz

1$ hugo -D
2hugo: collected modules in 960 ms
3Error: module "https://mega.nz/folder/7JYihLTB#FclpuFHngNKPNyXnRul2_Q" not found; either add 
4it as a Hugo Module or store it in "T:\\HTML-extras\\TRYOUTS\\hugo-test-1\\themes".: module does not exist

Comment from Bep

A related hint from me (which should get a more prominent place in the docs):

Hugo uses a /tmp dir for the cache if cace dir is not set (in config.toml or environment)
Go downloads the modules and write protects all directories
On MacOS I have experienced some occasional issues which I guess relates to MacOS trying to clean out these directories, but only partly succeeds.
Setting HUGO_CACHEDIR os env variable to something outside /tmp is the solution to the above. It’s also in general a good thing.

  1. The New Dynamic
  2. Hugo Modules for Dummies on the Hugo forums.
  3. Hugo docs on modules
  4. Hugo mod help page