WoJ
WoJ

Reputation: 30015

How to merge a template with a site?

Hugo works with themes one can download (or create from scratch). They live in their subfolder of the site root (namely themes).

When reading about customizing themes and playing along, I realized that a theme reproduces the structure of the root site (it has layout, static and similar folders, same as the root site).

Is it possible (and not discouraged) to copy a theme over the root of the site, and customize it from there?

I realize that I will lose the ability to update a theme, but it should not matter that much as i will heavily update it anyway. For completeness, I actually did the copy and my site did not change (it now now built without --theme=) but it may just be luck (or discouraged practices)

Upvotes: 1

Views: 158

Answers (1)

Jack Taylor
Jack Taylor

Reputation: 6217

This is possible, yes. The main folders from the theme (layouts, static, archetypes, data, and i18n) can be copied over to the root site folder without any change in functionality. Other folders that you copy over will be ignored (e.g. exampleSite). Most files in the root directory (e.g. theme.toml) are also ignored. So you should be able to copy everything over and have it just work, unless the theme author decided to put a config.toml or a content directory in their repo.

However, probably the easiest way to modify a theme is to clone the git repository into the themes directory, create a new branch in git, and make your modifications there. That way you can use git to merge any changes from the main repository into your version. Without git, this takes a lot more work. It also makes it a lot easier to swap your custom theme for a different one - just add the new one to the themes directory and change your config.toml.

Upvotes: 1

Related Questions