HUGO

Clarification regarding modules and themes

Hi,

In the (oldish?) documentation on themes, it is noted that it is possible to have multiple themes (in some order) and Hugo has a way of consolidating content from the different theme definitions. Of course, the user needs to figure out if this makes sense etc.

However, with the new modules approach, it is not entirely clear to me if this still applies. I have tried adding multiple modules (using the [module] tag more than once) to a site, but I get the error that the tag has already been defined.

Any pointers on whether multiple module support is intended or whether there has been convergence on the use of a single theme (and hence only a single module should be required) as the standard approach.

Thanks,
Seán.

If you have a module with a layouts folder then this layouts folder will be available to Hugo. If you have two modules with layouts folder then both will be available :wink: merged. I am not sure what happens if you have two modules with the same file in layouts. Probably the last added module in the config will overwrite the one before. Modules can be used for more than just themes.

Now about the [module] tag. Notice the double brackets [[ around the lines adding a module. That means “add a table row”. That row can have multiple items.

[module]
  [[module.imports]]
    path = "github.com/username/module1"

  [[module.imports]]
    path = "github.com/username/module2"

If you put these in wrong order it will lead to issues.

Regarding the order: It’s either a “first one wins” or “last one wins” scenario. The documentation should be more clear about that. But I myself never got into a situation where two modules added the same filenames to a system.

1 Like

Thanks for that clarification - much clearer now!

BR,
Seán.

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