HUGO

What is your strategy to keep themes up to date?

Hi.

I am using mainroad theme on my website. I cloned it from the original project and did some adjustments, mainly in colors. Theme hasn’t been updated from the original one for ages.

I was wondering what is your strategy for keeping modified themes up to date? I am thinking on simple recursive diff between the latest original version and mine. Save all my modified changes on the side, copy and update my changes again.

How do you do it?

Provided that the theme is mounted either as a git submodule or as a Hugo (Go) module.

Modified theme templates need to be placed in the /layouts/ directory under the root of a Hugo project.

So that you can update a theme from master while retaining your modifications.

See how to update Hugo modules in the Hugo docs or how to update git submodules in the Git docs.

Thanks for your answer. Indeed my theme is mounted as git submodule. Changes I did are partially in theme /layouts/ folder. If I understand you correctly in the root Hugo folder I should create /layouts/ folder and put all modified theme files? Shall I create the same folder structure as in theme?

For example I did change /themefolder/assets/css/style.css. Does this mean I have to copy it into /hugomainfolder/layouts/assets/css/style.css?

Similar /themefolder/layouts/partials/widgets/search.html into /hugomainfolder/layouts//themefolder/layouts/partials/widgets/search.html?

Cheers
Wojciech

Yes. To override a theme template you need to replicate its PATH under project-root/layouts

Regarding the theme assets folder I guess that changes need to reside under your project’s assetsDir, by default this folder should be project-root/assets/ while again replicating the PATH under the original theme folder.

I’ll try that and I will let you know if it works.