# Nested or sub modules

**URL:** <https://discourse.gohugo.io/t/nested-or-sub-modules/31861>\
**Category:** support\
**Tags:** modules\
**Created:** [March 20, 2021, 11:58am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861 "2021-03-20T11:58:12Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 20, 2021, 11:58am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/1 "2021-03-20T11:58:12Z")

</div>

My problem appears to be a duplicate of this thread

> [@Hugo theme module with nested module](https://discourse.gohugo.io/t/hugo-theme-module-with-nested-module/28199):
>
> I have a theme which I have set up as a Hugo module (with a go.mod). The theme then imports alpinejs from this repo - [https://github.com/gohugoio/hugo-mod-jslibs/tree/master/alpinejs](https://github.com/gohugoio/hugo-mod-jslibs/tree/master/alpinejs) - via its config.toml. If I do a hugo mod vendor from the theme directory I can see the partial in the \_vendor sub-directory. However, when I import the theme into my main project, the partial is not available. When running the Hugo server I’m getting the following error message. ...partial "jslibs/alpinejs/scri…

I just don’t understand the answer - is it possible to import a module, into a module?

Just like that thread, my nested module is not showing up in \_vendor or hugo config mounts.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [March 20, 2021, 12:44pm UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/2 "2021-03-20T12:44:15Z")

</div>

So, just like in that thread, what is the output of `hugo config mounts`. What is the content of the configurations of all three modules. Can you put a sample repository online.

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 20, 2021, 7:05pm UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/3 "2021-03-20T19:05:38Z")

</div>

The short answer is that yes, you can use nested modules (import a module that itself imports modules). (I’m going that with one of my repos at this very moment). @davidsneighbour’s questions will help figure out what is going wrong, but it’s not simply nesting that is the problem.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 21, 2021, 5:28am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/4 "2021-03-21T05:28:29Z")

</div>

> [@cshoredaniel](#):
>
> figure out what is going wrong, but it’s not simply nesting th

Thanks x 2 for your quick responses. I will put together a quick response now that I know that its possible.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 21, 2021, 7:46am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/5 "2021-03-21T07:46:26Z")

</div>

so here is the example:  
[GitHub - powerfulwebdesign/test-site: site for modules test](https://github.com/powerfulwebdesign/test-site) - imports the module below  
[GitHub - powerfulwebdesign/test-theme: ananke clone for modules test](https://github.com/powerfulwebdesign/test-theme) - imports the module below  
…/test-nested-module - imports 2x icon repositories

You should be able to just clone the top one, run “hugo mod get -u ./…”  
and see that the icon repositories (from config in test-nested-modules) don’t show up in “hugo config mounts” and in go.mod, only test-theme is listed.

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 21, 2021, 10:03am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/6 "2021-03-21T10:03:50Z")

</div>

I’m not claiming this is the core of the issue, but you should start by fixing this:

> <https://github.com/powerfulwebdesign/test-site/blob/feea22cc614d9476f17e2e127811ef4247514447/config.toml#L13>

The TOML spec says that only maps can follow maps, so any `module` config needs to be below the top level config options.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 21, 2021, 10:29am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/7 "2021-03-21T10:29:37Z")

</div>

Thanks for pointing that out. I have fixed it in the repository.

I still cant get the config files to merge and have all of the modules together in the parent module (test-site).

I’m having the same issue in two other sites, they are a bit messy to share.

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 21, 2021, 10:01pm UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/8 "2021-03-21T22:01:06Z")

</div>

> <https://github.com/powerfulwebdesign/test-nested-module/blob/48e2b0e0919a4976eae489f9216c6f95ed2a4d8a/config/_default/config.yaml#L6>

The typoed icons probably don’t help…

Continuing to look…

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 21, 2021, 10:37pm UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/9 "2021-03-21T22:37:58Z")

</div>

Are [github.com/FortAwesome/Font-Awesome](http://github.com/FortAwesome/Font-Awesome) and [github.com/twbs/icons](http://github.com/twbs/icons) also modules? if not that might be the issue.

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 21, 2021, 10:44pm UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/10 "2021-03-21T22:44:15Z")

</div>

Although I do successfully see (with the above fixed) `hugo server` working in

[https://github.com/danielfdickinson/powerfulwebdesign-test-site](https://github.com/danielfdickinson/powerfulwebdesign-test-site)

Is the main problem that the vendoring doesn’t bring everything up to the top-level site? If that’s the case I would also modularize the bootstrap and font-awesome repos

> [@cshoredaniel](#):
>
> Are [github.com/FortAwesome/Font-Awesome](http://github.com/FortAwesome/Font-Awesome) and [github.com/twbs/icons](http://github.com/twbs/icons) also modules? if not that might be the issue.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 22, 2021, 1:29am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/11 "2021-03-22T01:29:43Z")

</div>

> [@cshoredaniel](#):
>
> ccess

I am trying to add them as modules so they they can be accessed in “test-site”.  
My problem is the config for these nested modules doesn’t seem to be filtering down to “test-site”

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 22, 2021, 2:18am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/12 "2021-03-22T02:18:44Z")

</div>

> [@powerfulwebdesign](#):
>
> I am trying to add them as modules so they they can be accessed in “test-site”.

First, to clarify: you want [GitHub - FortAwesome/Font-Awesome: The iconic SVG, font, and CSS toolkit](http://github.com/FortAwesome/Font-Awesome) and [GitHub - twbs/icons: Official open source SVG icon library for Bootstrap.](http://github.com/twbs/icons) to be modules, correct?

If that is your intent you need to actually fork the repos and make them hugo modules.  
(That is `hugo mod init` and any `config.toml` (or equivalent).

AFAIK pulling in a non-module repo as a module won’t work, at least not with hand-coded ‘mounts’. It might work in a ‘pure import’ scenario, but I’m not sure.

I’ve run into this myself where I tried to import non-module and it just did not work.

I’ll see about a full demo soon.

* * *

I’m remembering now that I’m working on it, is that part of the issue is that go modules have specific expectations about versioning (tags). Will post more later.

Also, because you have an ‘assets’ **source** mount you won’t see sources below ‘assets’, IIRC, within that repo. (with `hugo config mounts`). Order may matter.

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [March 22, 2021, 3:55am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/13 "2021-03-22T03:55:53Z")

</div>

The dependency modules don’t need to be Hugo Modules.

Have a look at my sample setup: [[demo here](https://brave-yalow-9c02d4.netlify.app/)]

Main repo: [GitHub - pointyfar/hmd-main](https://github.com/pointyfar/hmd-main) imports:

- [GitHub - jgthms/bulma: Modern CSS framework based on Flexbox](https://github.com/jgthms/bulma)
- [GitHub - sindresorhus/modern-normalize: 🐒 Normalize browsers' default style](https://github.com/sindresorhus/modern-normalize)
- [GitHub - pointyfar/hmd-content](https://github.com/pointyfar/hmd-content)
- [GitHub - pointyfar/hmd-theme](https://github.com/pointyfar/hmd-theme)
  - imports:
    - [GitHub - feathericons/feather: Simply beautiful open source icons](https://github.com/feathericons/feather)
    - [GitHub - FortAwesome/Font-Awesome: The iconic SVG, font, and CSS toolkit](https://github.com/FortAwesome/Font-Awesome)
    - [GitHub - twbs/icons: Official open source SVG icon library for Bootstrap.](https://github.com/twbs/icons)

My main repo `_vendor/modules.txt` looks like this:

```auto
# github.com/pointyfar/hmd-content v1.0.2
# github.com/pointyfar/hmd-theme v1.0.4
# github.com/feathericons/feather v4.28.0+incompatible
# github.com/FortAwesome/Font-Awesome v4.7.0+incompatible
# github.com/twbs/icons v1.4.0
# github.com/jgthms/bulma v0.0.0-20210305201541-f26b871321a1
# github.com/sindresorhus/modern-normalize v1.0.0

```

Other than the repos under my own name, the other dependencies are not Hugo Modules.

* * *

* * *

* * *

Have you also tried the [marked solution](https://discourse.gohugo.io/t/hugo-theme-module-with-nested-module/28199/6) in the other topic you linked to?

Your nested module [`config.yaml`](https://github.com/powerfulwebdesign/test-nested-module/blob/main/config/_default/config.yaml) is inside a config dir. It must not be inside a config dir.

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 22, 2021, 4:49am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/14 "2021-03-22T04:49:39Z")

</div>

> [@pointyfar](#):
>
> Other than the repos under my own name, the other dependencies are not Hugo Modules

Hmmm… I was wrong on that. I have more testing to do, I guess. (I’ve had trouble with non-Hugo modules in the past, but it’s probably something else that was going on, given that it works for you).

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 22, 2021, 5:09am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/15 "2021-03-22T05:09:24Z")

</div>

> ignoreConfig  
> If enabled, any module configuration file, e.g. config.toml, will not be loaded. Note that this will also stop the loading of any transitive module dependencies.

[https://github.com/powerfulwebdesign/test-nested-module/blob/48e2b0e0919a4976eae489f9216c6f95ed2a4d8a/config/\_default/config.yaml#L12](https://github.com/powerfulwebdesign/test-nested-module/blob/48e2b0e0919a4976eae489f9216c6f95ed2a4d8a/config/_default/config.yaml#L12)

I believe this is what is messing you up. I see why given font-awesomes’s defaults, but I will have to check @pointyfar’s repo to see how they handle it.

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 22, 2021, 5:53am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/16 "2021-03-22T05:53:11Z")

</div>

So here is the real problem:

You are pulling v4.7.0 but wanting /svgs which was introduced in 5.6.0 of FortAwesome/Font-Awesome:

> <https://github.com/FortAwesome/Font-Awesome/blob/ce084cb3463f15fd6b001eb70622d00a0e43c56c/UPGRADING.md#550-to-560>

You need to to do `hugo mod get -u github.com/FortAwesome/Font-Awesome@5.15.3` (or the version you actually want).

In addition to what was mentioned about not using `config` directory but `config.yaml` in your lower level module.

To see why `hugo mod get -u ./...` doesn’t automatically get the latest version of that repo see:

[https://golang.org/doc/modules/version-numbers](https://golang.org/doc/modules/version-numbers)

The @5.15.3 thing reminds me of what the problem was with non-Hugo (non-Go) modules – hugo mod get -u ./… will consistently fetch the wrong version of font-awesome in the current circumstance. The only way to fix _that_ issue is to fix the tags in the repo you use to be compatible with Hugo/Go modules (I think it would be enough to eliminate all the vx.x.x tags from the repo, and just used the latest master). Go version module versioning is a pain especially with non-Go repos.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 22, 2021, 7:24am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/17 "2021-03-22T07:24:30Z")

</div>

Thanks so much for providing the example. I’ll have a good look through it - looks similar to what I’m trying to do.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 22, 2021, 9:22am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/18 "2021-03-22T09:22:01Z")

</div>

Thanks to everyone who has replied.

I have moved the “test-nested-module” config file into the root of the site.  
I have manually updated the font-awesome repository specifying the non-standard version.

It’s finally working. I realised that I didn’t understand the solution in the previous issue.

I’ll note it in the docs so its clear that only the top level site can use a config DIR.

---

<div class="post-metadata">

**Author:** ![powerfulwebdesign](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/powerfulwebdesign/32/14227_2.png) [@powerfulwebdesign](https://discourse.gohugo.io/u/powerfulwebdesign)\
**Post date:** [March 22, 2021, 11:51am UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/19 "2021-03-22T11:51:39Z")

</div>

Thanks for the help.

Have you personally had any luck with (local) module replacements via the config files?  
I can see that the path needs to be relative to the theme directory, but when modules are nested, I am assuming that the path is being resolved relative to the parent site module rather than the nested module.

---

<div class="post-metadata">

**Author:** ![cshoredaniel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/cshoredaniel/32/19684_2.png) [@cshoredaniel](https://discourse.gohugo.io/u/cshoredaniel)\
**Post date:** [March 22, 2021, 4:54pm UTC](https://discourse.gohugo.io/t/nested-or-sub-modules/31861/20 "2021-03-22T16:54:54Z")

</div>

> [@powerfulwebdesign](#):
>
> Have you personally had any luck with (local) module replacements via the config files?

FWIW using the HUGO\_MODULE\_REPLACEMENTS environment variable works for me (with absolute paths). I know it’s not quite what you asked, but I am not a fan of committing local paths into repos, so I never use the config file replacements.

[Next page](https://discourse.gohugo.io/t/nested-or-sub-modules/31861.md?page=2)
