Two websites, same theme

I have two websites and I want to use the same theme for them. Currently, I copy the theme folder from one website to the other one on a regular basis (the theme evovles aswell).

Is there any way to put both websites and the theme in the same “root” so that both websites use the same theme-folder?

How about the following?

# build site A
hugo --config config-a.toml

# build site B
hugo --config config-b.toml
$ ls
config-a.toml
config-b.toml
content-a/
content-b/
themes/your-theme/
# content-a.toml
contentDir = "content-a"
theme = "your-theme"
# content-b.toml
contentDir = "content-b"
theme = "your-theme"

I like the approach – but what about website-specific archetype, data, layout and stuff?

You can also define those at each a config file.

  • archetypeDir
  • assetDir
  • dataDir
  • layoutDir
  • staticDir
  • publishDir

Thanks! That sounds like a doable workaround for me. I hope that I could simply put the theme somewhere else and reference it from both but that apparently doesn’t work. :frowning:

If you manage your website using Git and GitHub (GitLab, and so on), you can publish your theme and pull it as a git submodule on each a site content repository.

3 Likes

Oh that’s even nicer – thanks for the suggestion!

1 Like

Your welcome! If you have no more question, please close this topic. :smiley:

That’s kind of buying a Mercedes car so you can listen to your mixtape cassette tape.

Create two repositories for your two sites. Move your theme to a third repository. Add the theme as submodule to your two websites. That’s the way you install themes anyway.

If you change something in the submodule (your theme) on either site, it will show you an info should you run git status on the site itself. Follow this solution to submit your changes to the submodule:

And then load the changes in each repo by updating the submodule.

This way you have two websites logically separated and you got your theme separate in case you want to add a third site with the same theme.

1 Like