banjocode Working With Hugo Themes and Git Submodules

Working With Hugo Themes and Git Submodules

Working with Hugo themes you probably use git submodules. These are basically subrepositories within your repository. They can be used for several different reasons, but the main one is probably so you can download updates.

1 min read

You also need a submodule theme to be able to host on Netlify.

Adding a submodule theme

Execute this in your root folder to add the theme to the theme folder.

git submodule add https://github.com/name/my-theme.git themes/my-theme

You also need to configure the config.toml file to be able to use the theme.

theme = "my-theme"

Update your theme to the latest release

If you want to download the latest release of the theme to your Hugo site, you can to that with this command.

git submodule update --remote --merge

You also need to add, commit and push to changes in your main Hugo repo for them to work.

Download your submodule on a new computer

If you git clone your Hugo repo on a new computer, you won’t get the theme because it is a submodule. You can download it by executing this command in your root folder:

git submodule update --init --recursive