Hugo

"Module not Found..."

I’m trying to figure this out and would appreciate any feed back. Basically, I’m moving stuff to repos, and also trying to be more HUGO MODular, but have run into some strange behavior.

I have a repo which will be the main content repo (AKA “the website”). This repo pulls in a theme via mods from a local folder (I know that routing the theme locally rather than via github will be faster/easier for rapid development).

So my main site/config.yml file looks like:

...

themesDir : ../ #theme folder lives above

module :
  imports :
    - path : hugo-theme

...

So far, so good (this repo also has a go.mod and go.sum file.

“Hugo-Theme” is a repo with a go.mod and go.sum file as well as a config.yml file where I want to pull some dependencies.

In the past I have used Hugo Mods to pull some JS libraries from Github – I use this fro my dependency management. It seems to work well (at least for my use cases).

So, within hugo-theme/config.yml it looks like this:

module :
  imports :
    - disable : false
      path : github.com/processing/p5.js-website
      mounts :
        - source : src/assets/js/
          target : assets/js/vendor

And, within hugo-theme/layouts/index.html I have:

{{- $p5 := resources.Get "js/vendor/p5.min.js" -}}
{{- with $p5 -}}<script src="{{ .Permalink }}"></script>{{- end -}}

When I run the site I get the following readout:

$ hugo serve -D --disableFastRender
hugo: downloading modules …
go: finding github.com/processing/p5.js-website latest
go: downloading github.com/processing/p5.js-website v0.0.0-20191128063215-f4e4dec930b8
go: extracting github.com/processing/p5.js-website v0.0.0-20191128063215-f4e4dec930b8
hugo: collected modules in 53101 ms
Error: module "github.com/processing/p5.js-website" not found; either add it as a Hugo Module or store
 it in "/.../Documents/GitHub".: module does not exist

Hmmmmmmm…

and the thing is: it all works when the module is listed and imported when it is the in the main site/config.yml.

I’m not sure whats happening… thoughts?

Check whether there is some difference in the generated hash between earlier and recent versions of Hugo.

I encountered the “Module not found” error in a theme submission at the Hugo Themes repo, more here: https://github.com/gohugoio/hugoThemes/issues/713#issuecomment-557814781

1 Like

so I just read this: https://kodify.net/hugo/theme/config-theme-toml-difference/

Which says:

The config.toml file that’s included with most themes (usually in the theme’s /exampleSite/ folder) contains the theme’s example settings . This file is not a configuration file and does not affect Hugo’s behaviour (and we can even safely delete it). We use a theme’s config.toml file only to see what theme settings we should include in our configuration file and the values those options accept.

Is this true? I could understand it not being used if within the /exampleSite/ folder, but if it is a top-level config file, I would assume that it would be folded into the site’s config ?

(I’ll also check on those hashes…)

The quote you linked to is from 2017.

Since https://github.com/gohugoio/hugo/pull/4514 was merged in 2018, config files directly under the root of /theme/ gained the following functionality:

This allows a config.toml in the theme to set

  1. params (but cannot override params in project. Will also get its own “namespace”, i.e. {{ .Site.Params.mytheme.my_param }} will be the same as {{ .Site.Params.my_param }} providing that the main project does not define a param with that key.
  2. menu – but cannot redefine/add menus in the project. Must create its own menus with its own identifiers.
  3. languages – only params and menu . Same rules as above.
  4. new outputFormats
  5. new mediaTypes

The config under /exampleSite/ does indeed refer to the exampleSite project and as such it is not inherited by a project that uses its parent theme.

But the config under the root of a theme is inherited by a project that uses this theme.

The config under the root of a Hugo project can override the config of a theme, but not the other way around.


cc: @bep

Cool, just making sure. :+1:

Hashes look good ( i think? )

And now I’m getting the following error…

go get .: path /Users/.../Documents/GitHub/hugo-theme is not a package in module rooted at /Users/.../Documents/GitHub/hugo-theme

doe this help clarify the issue?

Actually I am probably not the best in debugging Go(aka Hugo) modules.

but let’s give this a try. What is the Go version installed locally?

Try issuing the command go get -v with the -v flag that is.

Did the module mount?

If not you may need to provide access to your project for us to have a look locally.

let me make a set of “clean repos”, see if i can’t reproduce, and then i’ll share with all.