Strategies for reusing a theme for multiple sites


I imagine the following approach for realising and organising a number of sites:

First, there is one common theme which includes frequently required assets (like for example jQuery, bootstrap, font awesome, and other vendor scripts). Also this theme provides common base templates. In contrast to a theme components the theme should render a complete site with some navigations, header and footer area, etc.

Second, each single site uses this theme and overrides specific templates in it’s layout/ directory. Also some cosmetic aspects are customised using a specific stylesheet in static/css/.

Is this approach reasonable? Or is there a better way to combine a central management of vendor assets and a reusable base layout with different sites based on it? In another system I am used to create one dedicated theme for each site, but since almost all sites are based on Bootstrap I guess this redundancy is not really elegant anymore.

Looking forward to some pointers and best practices.

Yes, that’s pretty much how themes work, even now more so with these features:

1 Like

I start with a “starter” project and add what I call “Layout Modules”—one for the basices—others for very specific things like events. Generally speaking, this works really well.

Here are the repos (caution they’re specific to my workflow). They’re a work in progress, specifically I want to simplify my set of base modules to be as general as possible.

1 Like

Your layout modules look quite near to what I imagine. But I wonder why you collect them in a layouts directory instead of providing them as a theme?

Just saw that these are indeed used as themes or themes components.

theme = ["hugo-layout_module-base", "hugo-layout_module-books", "hugo-layout_module-events"]

Exactly: I use them as themes, but the word “theme” doesn’t mean much to me in this context so I changed it (themesDir = "layout_modules"). I also like to have my theme files next to my layouts directory.

1 Like