Multiple site with one centralised base

I have this requirement where I will have a base theme, I am planning to host around 50 websites with this same code (all config values will pick up from ENV variables) the only thing that will change is contents of content directory.

What will be the best way to achieve this so it’s still remains easy to maintain and any change I make in future like adding new layout, js or css it takes effect in all sites without doing pull requests in all separately.

I haven’t tried it, but assuming all on the same machine, creating a sim links from the base theme to each site. Should work, but have never tried that, and I’d worry about the danger of the theme being changed by accident. Any change to the theme would be automatically applied to each site.

Of course since each site would need to be regenerated with hugo, that’s not a big difference than doing pull requests in each site.

Given the above, I’d still have the theme be it’s own git repository, and then include the theme repository as a submodule for all the sites that will use it. This will meet for a few common needs:

  • Easily update all sites with theme changes by updating the git submodules
  • Easily develop & test changes to the theme using a test site without affecting all the live sites
    • Could even use different versions of the theme in different sites if any breaking changes are made by using submodule and tags/branches on each live site as they are updated

If no breaking changes, would be easy enough to update all the sites with a script to pull the submodules and run hugo for each site.

I would strongly recommend that you read up on theme components – and especially the part about file mounts.