How to mount shared static folder between multiple sites?

I run hugo v0.120.4.

I have the following mutlisite structure:

main-site/
   config/
      _default/
         hugo.toml
   content/
   hugo.toml
   static/
      css/
sub-sites/
  site-a/
     content/
     static/
        images/
     hugo.toml
  site-b/
     content/
     static/
        images/
     hugo.toml

From the main-site directory, I can successfully do hugo server --config=sub-sites/site-a/hugo.toml.

I want to share theme, theme configuration and some custom css between the main-site and the sub-sites site-a and site-b.

I’ve read:

I want to mount main-site/css as static/css for site-a.

In main-site/sub-sites/site-a/hugo-toml I got the following:

[module]
[[module.mounts]]
    source="sub-sites/site-a/content"  
    target="content"
[[module.mounts]]
    source = "static"   
    target = "static"

The content directory gets correctly mounted, and here source is relative to main-site.

For site-a I cannot manage to mount main-site/static as static nor main-site/static/css as static/css. How can I do this?

Solved!

Previously tested only with hugo server. My mistake was to rely on visual feedback (missing css).

After testing to build with hugo and checking the results in the public directory it turns out that the static directory gets mounted correctly.The css was there but the link including the css in the page header was missing a pipe to relLink.

Now the mounted css gets included correctly.

<link href="{{ "css/theme-relearn-tweaks.css" | relURL}}" rel="stylesheet">

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