Accessing Data files from a module

My site imports a theme (seperate repo) as a module which is used by multiple other sites. I need to keep a Data file within this theme module so it is accessible to multiple sites, but Hugo seems to lose visibility of the Data folder if it’s located within the module.

Site structure:

- Main site
    - content
    - layouts
    - config.yml
    ....

- Theme repo/module
    - Data
        - navigation.yml
    ....

How I import the module for use:
config.yml

module:
  replacements:
    - "local/component-library -> ../../theme/component-library"
    - "github.com/user/theme -> ../../theme/"
  imports:
    - path: "local/component-library"
    - path: "github.com/cloudcannon/bookshop/hugo/v2"
    - path: "github.com/user/theme"

How can I access the data file within my theme module?

My memory is a little hazy, but I suspect you need to mount it (either in the project’s or module’s config).

1 Like

Is the directory name “Data” or “data” ?

1 Like

@bep Thank you, that’s fixed it!

That was a typo sorry, it was supposed to be lowercase. Solved by mounting the data directory:

[[module.mounts]]
source = "data"
target = "data"
1 Like

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