Mount multiple directories as Hugo `assets`

Is there a way to mount multiple directories (e.g. node_modules and assets) to Hugo assets component for use as resources?

The following didn’t work. Not terribly surprised as it likely causes problems for all of the other mounts:

module:
  mounts:
    - includeFiles:
        - assets/*
        - node_modules/*
      source: ./
      target: assets

If you want to mount both of these to assets:

mysite/assets/
mysite/foo/

You need to mount both:

module:
  mounts:
  - source: assets
    target: assets
  - source: foo
    target: assets

https://gohugo.io/hugo-modules/configuration/#module-config-mounts

When you add a mount, the default mount for the concerned target root is ignored: be sure to explicitly add it.

1 Like

That worked beautifully. Thank you!

That note was confusing to me since it wasn’t immediately obvious to me from the docs that multiple directories could be mounted to the same component. I’ve opened a PR adding your example to the note in case it’s a problem that others may have as well: add example to note in module mounts by AlanBreck · Pull Request #2075 · gohugoio/hugoDocs · GitHub

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.