Looking Up Module Mount Points

Hi all,

I’m working on a new site using Hugo’s modules and theming support. I’ve divided my theme into a few modules:

  • base
  • blog
  • photos

I also have a few additional themes that contribute specific small components.

Each of these modules has a collection of templates for their particular section, and I’ve set up mounts in the top-level hugo.yaml file to place them in virtual subdirectories according to their section:

    - path: base
    - path: blog
      mounts:
        - source: assets
          target: assets/blog
        - source: layouts/_default
          target: layouts/blog

I’ve mostly gotten the working since the layout templates in each section haven’t needed to use partials from their own theme or another theme. However, I’ve been working on a new theme component that does have a few partials that reference each other. It has some mounts like this:

    - path: my-component
      mounts:
        - source: assets
          target: assets/my-component
        - source: layouts/partials
          target: layouts/partials/my-component

The problem I’m running into is how to build a path to the correct partial template when the top-level site has moved it via a mount. Is there a way for the template to know this? Is this a good approach, or is there a better way to do this?

Thanks!

I must admit I don’t get all of your setup to my head. It looks maybe overly complicated

Usually you would provide the theme components of the blog in the themes subdirectories as:

theme/layouts/blog
theme/assets/blog

And just use the theme.

No need to mount that in the main site. The components will be available at the right path an can be addressed.

If you tend to have some generic theme to be mapped to any folder … uh guess this will need extra config and code to tell where the components are.

but nevertheless partials can be called with a path partial/mycomponent/tool.html. Should work with mounts.

You cannot get the mount target from within hugo. But maybe you can do a readFile on the site config (never tried) or go with some config/data file to define the place and use that as the partial name to call.

If I got it wrong…please help me out with your setup and intention maybe a repo share…

P.s. if you always use your theme with all parts. There is a Theme Components in the docs. Stated as outdated …but maybe …