Inherited Layouts

Can layouts inherit other layouts like the do in Jekyll? I feel strange creating so many different layouts that have essentially the same bones (partials including head, header, footer), but with different content injected into the body.

Including the same partials in all of my layouts seems to violate DRY. Is there something I’m missing to get around this, or is by design?

I hate to draw comparisons w/Jekyll because in only a day or two I’ve found Hugo to be far superior.

Currently no.

Use the search in the upper right corner and search for “ace” and it will bring up more context.

For Ace templates, it will happen — maybe I will have a look at the problem.

1 Like

See

http://discuss.gohugo.io/t/inheritance-with-ace-templates/

There is movement in this area in the stdlib:

Good news for Go 1.6:

2 Likes

Is there any additional work necessary for a future Hugo to support the new block keyword coming in Go 1.6? I know it isn’t part of Hugo 0.15.

Seems like it would “just work” once Hugo can be compiled with 1.6, right?

See

Needs some doc …

I am excited enough about blocks that I would be willing to take a stab at it—I can’t get to it for a week or two though maybe. Were you thinking just another section in the Go Template Primer?

Yes that makes sense. You may get some inspiration/copy-and-paste from the Ace templates docs, as the logic for picking the base template is identical.

The doc issue is here:

You can actually get around this by not using single.html and list.html for your type layouts. I use block.html instead and put only the block div (BEM methodology) only into the html template file. Then I do as much as I can to use the layout/_default and render the block view instead of repeating the same header and footer stuff on all the layouts. I find rendering views of blocks in this way a much more sustainable approach since it favors composition over inheritance.

1 Like

Would you rather discuss the block documentation here or on the GitHub issue?

GH issue.