Is it good practice to create a new theme?

Hi all. I’m new to Hugo. I’m trying to figure out if it is good practice to create a new theme or if it’s okay to simply build a theme in the root directory?

Thanks

Separation of code. I think you should go with a separate theme, as you can easily try iterations and variants.

Either works. If you want to produce themes and share them, make a theme. If you are making just your site, build your templates in the site project. You can always move it into a theme later. :slight_smile:

2 Likes

I’ve recently asked the same question.

I agree with @maiki. If you don’t plan sharing a theme (or reusing the same theme for different projects), put templates in the site root. IMO it’s cleaner. You can move the files later in case you have to.

If I want to try layout variants, I’d rather use git branches.

¯_(ツ)_/¯

Thanks for the reply all. Think I will try creating a new theme, if only for learning purposes

Just a minor addition:

Since Hugo 0.42, which supports theme components, I always create a new theme for a project called default.

When I want to test a different layout, I build a new test theme with two files only (in the first instance):

  • themes/test/assets/css/style.css
  • themes/test/layouts/_default/baseof.html

You only have to change a single line in config.toml to test your new theme:

theme = ["test", "default"]
1 Like