Layered Module Imports

I currently have a module that has all our styling guides that I have in the _default folder. I then want to blend it with a content module that resides under an environment. Is this supported? The only way I can get it to work is to duplicate the import for the style guide into the sub environment.

You lost me in the first sentence. I suspect you need to either point to your source (on GitHub) or give a more complete explanation (folders and files).

This is how I am trying to configure it. I have tried module: _merge: deep also to no avail. I am running hugo serve -e internalteam. Unless i copy all the imports from the _default/config.yaml into internalteam/module.yaml, I get just a blank page. I had to pull some of the identifying data out.

config/_default/config.yaml

module:
  imports:
    - path: internal.local/repo/Common-styling.git
      disable: false
      mounts:
        - source: assets
          target: assets
        - source: static
          target: static
        - source: layouts
          target: layouts
    - path: github.com/google/docsy
      disable: false
    - path: github.com/google/docsy/dependencies
      disable: false

config/internalteam/module.yaml

imports:
  - path: internal.local/repo/Documentation.git
    disable: false
    mounts:
      - source: content
        target: content

One clue in your setup is to get the definition of module path in order. It must be one of

  • A Hugo Module path. For GitHub repos without a go.mod file that is the root of a repo (e.g. github.com/google/docsy) without any .git suffix. For Hugo Modules (repositories or sub folders with a go.mod file), the path is the path in the top of the go.mod file (which may have a major version suffix, see example below).
  • To import GitHub repos etc., you first need to init your own project as a Hugo Module (hugo mod mylocalmodule).
  • path can also point to folders in themeDir

There are examples of this in the wild, e.g. docuapi/config.toml at master · bep/docuapi · GitHub

I have it working. I am just trying to not have to duplicate the _default module imports for all my teams repos. I run this with hugo -e internalteam for example. I am just trying to merge the module stanza from default into the sub environments and didn’t know if that is possible.

This works.

config/_default/config.yaml

module:
  imports:
    - path: internal.local/repo/Common-styling.git
      disable: false
      mounts:
        - source: assets
          target: assets
        - source: static
          target: static
        - source: layouts
          target: layouts
    - path: github.com/google/docsy
      disable: false
    - path: github.com/google/docsy/dependencies
      disable: false

config/internalteam/module.yaml

module:
  imports:
    - path: internal.local/repo/Common-styling.git
      disable: false
      mounts:
        - source: assets
          target: assets
        - source: static
          target: static
        - source: layouts
          target: layouts
    - path: github.com/google/docsy
      disable: false
    - path: github.com/google/docsy/dependencies
      disable: false
   - path: internal.local/repo/Documentation.git
     disable: false
     mounts:
      - source: content
        target: content

This does not work.

module:
  imports:
    - path: internal.local/repo/Common-styling.git
      disable: false
      mounts:
        - source: assets
          target: assets
        - source: static
          target: static
        - source: layouts
          target: layouts
    - path: github.com/google/docsy
      disable: false
    - path: github.com/google/docsy/dependencies
      disable: false

config/internalteam/module.yaml

imports:
  - path: internal.local/repo/Documentation.git
    disable: false
    mounts:
      - source: content
        target: content