Adding a theme as a submodule or clone?

In https://gohugo.io/themes/installing-and-using-themes/ it is suggested to add them with git clone:

git clone https://github.com/spf13/hyde

While in https://gohugo.io/getting-started/quick-start/#step-3-add-a-theme it uses git submodule:

git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke;\

What are the pros and cons of each method or what has been your experience with using each of them?

There is a third option (as seen in https://github.com/gohugoio/hugoDocs/tree/master/themes/gohugoioTheme), which is a git subtree …

Which I guess makes the confusion complete, I guess …

I would say this:but

Submodules is, in most cases, your best choice. You can easily pull in updated theme(s) when needed.

Assuming your project is already a git project, then git clone sounds a little weird, and we should probably fix that. It may be a good option if your site isn’t a Git project. I.e. git clone some theme and then delete .git folder. Maybe also if you plan to use a theme as a starting point and never intend to synch in changes from the source.

The reasons why we use sub tree in the docs site is mainly:

  • We have a “mirror” of the docs in the main Hugo project (below /docs), so /docs is a subtree with the theme as another subtree …
  • Ready to build (hugo server) documentation is with this automatically packaged as part of the source distribution when we release, including theme and all.
  • We can also add documentation changes as part of the code changes in the same PRs if we need to.

I’m just starting out with Hugo and read the quickstart and then theme docs, was a bit confused about which is the best path to follow, so would probably help beginners to have it consistent in documentation :slight_smile:

thanks for detailed answer :slightly_smiling_face:

Maybe this isn’t the best place to ask, but after applying “git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke;” my cmd just hangs. Am I missing something here?

Leave off the semicolon?

Yeah, I don’t have the semicolon, tried that the first time.