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.

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

git submodule add https://github.com/spf13/hyde.git 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.

https://res.cloudinary.com/forestry-demo/image/fetch/c_limit,dpr_auto,f_auto,q_80,w_640/https://forestry.io/uploads/2018/02/submodules-1.png

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