Open navClose nav

Using a Git Submodule for Your Theme

If you have a repository for your Jekyll or Hugo project and you want use a different repository for your theme, you should set up your theme repo as a Git Submodule.

Hugo modules

Hugo has also its own module management system, it’s fast and offers more possibilities. Here’s a tutorial to get started with Hugo modules.

To add a theme as a Git Submodule, run the following command from the root of your project:

git submodule add themes/hyde

Be sure to add the correct URL to your theme repo and the correct path to where you want this repo to live within your project.,dpr_auto,f_auto,q_80,w_640/

Once you create the submodule, you’ll notice a .gitmodules file in the root of your project. Commit this file as well as the module inside of your theme directory to your project.

If you need to make a change to this theme, the changes should be pushed to the original repository you created the submodule from. You can then update the submodule on your site with the following command:

git submodule update --remote

This is also how you update a third-party theme that you have installed as a submodule.

Don’t forget to set the theme you just installed as your active theme! In Hugo this is your config.toml file, and in Jekyll this will be _config.yml.

Last updated on February 1, 2018