Override a theme's templates

Hi,

I had removed some functionality from my theme before making it a public repo.

So now my site content and the theme are in different git repos. The theme is a public repo and the site is a private one. I use the theme using git submodule. So people who use my theme do not get that feature (basically a partial file and a small change in single.html with some personal info).

I want to keep the 2 files specific to my site in a folder in my site repo and copy it into the theme folder during the hugo build process.

How can that be done today? I cannot “fork” my theme as git doesn’t allow forking one’s own repo.

To override a theme’s templates you need to include a /layouts/ directory under the root of your project and create the necessary templates with the changes.

1 Like

Git has the concept of branches and merging them. A “fork” functionality is a feature of your web-based git hosting site.

You can create a new repo and push your changes to it. It might not be an automatic process like pressing the “fork” button, but it works as expected. :slight_smile:

Thanks, branching is not an option for me as I wanted to keep some private files.
Another repo ( basically two versions of the same theme) would be a hassle.

The solution from @alexandros was perfect for me!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.