Hugo: Theme inheritance

Created on 27 Oct 2016  Â·  14Comments  Â·  Source: gohugoio/hugo

I would appreciate so much that Hugo had theme inheritance abilities. This is what we can do on eg. wordpress and this functionality is extraordinary: this way, you can make your own theme based on an existing one, while still getting updates from the base theme. If you don't do so and want to get the updates, you have to merge some git branches (for instance), and that contributes to keep non-developers away from using hugo.

What I suggest is like Wordpress: in the child theme, setting which is the base theme (that can be done inside the theme's config file like parent = "hugo-material-docs"), and always preferring a new file when available.

Note: to my mind this functionality does not seem to exist inside any other static site generator for now, but I assume this is a must-have in a widely used static site generator!

What do you think of it?

Enhancement Stale Wish

Most helpful comment

@lebarde please don't start discussions on tiny implementation details when the full picture is so unclear. That is just a waste of everyone's time. I have said it before, but I can say it again: Before we even start to think about theme inheritance, we need to handle external resources in a much better way than it is today. And that is a task much bigger than a simple config file.

All 14 comments

this is a must-have

That is taking it too far, me thinks. There are lots of theme related stuff that comes further up the ladder than this one (standards, widgets ...).

There are lots of theme related stuff that comes further up the latter than this one (standards, widgets ...).

Do you mean functionalities that are more important to develop first? (in which case I agree!)

Do you mean functionalities that are more important to develop first?

Yes, I meant to write "ladder".

Okay! Anyway I think this is not too difficult a task to develop.

On the Hugo discussion site, this thread is similar, to wit:

For each directory (anywhere) named themes/, everything under a certain subdirectory of it is fallback for everything outside that themes/ directory; themes/../config determines which subdirectory.

What new behavior would we (hypothetically) obtain? Perhaps sub-themes, or theme families.

So fileOne would be inherited from [parent theme] themeOne, and fileTwo would be inherited from [child theme] themeTwo.

What Hugo should have is:

  • A way to say that a theme extends another theme, i.e. in some theme config extends: someother-theme

It does not need to be hard, but we should probably first address the somewhat clumsy theme addressing scheme (now people have to manually download themes and put them in a magic folder).

@bep, for the naming convention of a config file: Actually a lot of theme designers already use config to put a sample main config file inside the theme tree, so using this name would break all those themes.

What would you tell about a theme.toml (or theme.yaml, and so on) for a theme configuration filename? IMO that would be clear enough.

theme.toml is already part of themes; e.g.:

https://github.com/sethmacleod/aerial/blob/master/theme.toml

Snif… What would be suited best?

If that filename is less used than config.toml, maybe we could contact the theme creators who use that name. What else could be imagined as a filename?

@lebarde please don't start discussions on tiny implementation details when the full picture is so unclear. That is just a waste of everyone's time. I have said it before, but I can say it again: Before we even start to think about theme inheritance, we need to handle external resources in a much better way than it is today. And that is a task much bigger than a simple config file.

@bep Thanks for clearing the situation!

You are right about the fact that the picture is unclear. When I dived into the code I effectively saw that I would have to hook every access to a file to look for a parent. That would be made things most complicated.

It does not need to be hard

And I may have misinterpreted your statement. Anyway, I did not know (or remember) that you said that. As you said it did not need to be hard, I started to try. I recognize that external resources have to be handled another way before starting that, so I will not go further on that case!

When I dived into the code I effectively saw that I would have to hook every access to a file to look for a parent. That would be made things most complicated.

The inheritance part of this is easier than you think, but again, this must come after some other thing.

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bep picture bep  Â·  3Comments

MunifTanjim picture MunifTanjim  Â·  3Comments

VoidingWarranties picture VoidingWarranties  Â·  3Comments

carandraug picture carandraug  Â·  3Comments

digitalcraftsman picture digitalcraftsman  Â·  3Comments