Multiple themes


#1

My site is divided into 3 sections: root (homepage, about…), /blog and /documentation.
These 3 portions being quite different in designs, my feeling is I should handle 3 themes: one for each parts of the site. However, as far as I know, Hugo only handles one theme per site.
Plus, I would like to reuse existing templates as much as I can (I would prefer not to create one theme myself, but just install existing ones for blog and docs at least).

Especially, I know I can force pages to grab a specific layout but I would love something like this:

layout = "my_theme/my_layout"

Have you ever experienced such need ? Do you have any suggestions on how to manage themes in that situation ?

NOTE: I already visited Section vs Separate Site for two different themes and older How to have two themes for different sections of a site? but I’d rather not split the site into three mini sites…


#2

You would do something similar to the pseudo layout front-matter you posted.

Have a look at:

In Hugo, a layout is specified by a combination of type and layout. Both of these have default values. So you can change one or both to get the kind of customization you want.


#3

Thanks for the reply !
Yes, that is a workaround. But, correct me if I am wrong, this will work only within the same theme, right ?
If I understand correctly, type and layout cannot bypass current theme and will just choose a template within theme XYZ.
However, what I need is to be able to choose from themes XYZ, ABC and RST…


#4

Those have very little to do with the theme… it again comes down to the lookup order…

Let’s say you set the type to foo. If you have SITE/layouts/foo/single.html, it will use that for rendering that single page (even if you have SITE/themes/some-theme/layouts/foo/single.html). So if you like, you can put the custom types and layouts in your SITE/layouts/ directory, which will always take precedence over the same type/layout in any theme.


#5

Sorry but I am not following: how will the lookup order of layouts help in my use case ?

Let’s be a bit more pragmatic one second. Say I have three pages: home, blog and doc.
Each pages respectively receives layout="home", layout="blog" and layout="doc".
As well as type="home", type="blog" and type="doc".

Now, how lookup order will go to respectively SITE/themes/HOMETHEME/layouts/HOME/single.html, SITE/themes/BLOGTHEME/layouts/BLOG/single.html and SITE/themes/DOCTHEME/layouts/DOC/single.html ?

See the problem ? I don’t see lookup order jumping through themes folders as far as I know :slight_smile: would love to though