How to merge, and not overwrite, Hugo mount directories?

I want to have two different static directories with my project. From searching and reading the docs, I learned that this is possible with mounts.

This is my goal:

# Local folder Hugo virtual folder
1 content/assets/ /static/assets/
2 static/ /static/

I use this mounts config:

module:
  mounts:
  - source: static
    target: static
  - source: content/assets
    target: static/assets

The problem is that I also have an asset subdirectory in static. So there are two:

  • /content/assets/
  • /static/assets/

With the above mount configuration, Hugo only renders content/assets/ unto static/assets/. But the original static/assets/ directory is ignored (or overwritten).

How do I tell Hugo to merge the content/assets/ folder with the static/assets/ folder I already have? :thinking:

Could you also try to explicitly mount static/assets on to static/assets?

1 Like

Sidenote: I assume you might have a static directory in your content directory because of some IDE complications with “path not found” and markdown previews? You probably can map those directories in the IDE instead of Hugo and keep everything in static.

1 Like

Thanks, this fixes the situation. :slightly_smiling_face: Not sure why I overlooked such an obvious things.

That could be but it’s not my setup. I have two repositories for my website, one for the content (which contains the content/content and content/assets folders) and one that has all the other files (theme, Hugo config).

This way I have one repository for both my images and Markdown content files. (I know images could also live inside content with page bundles, but I don’t like to clutter my subdirectories in content/content.)

My 50 cents about this is that:

  • Mount merges happens within a component type (e.g. static, content, assets, i18n etc.)
  • Due to the processing order a /content/foo.jpg will win over /static/foo.jpg – but this has nothing to do with any mount merging
1 Like

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