You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hugo new theme does not create a baseof.html #3576
As Block-Templates are the new default I think that the directory layout of a theme created by hugo new should reflect this and create a baseof.html in _default.
We make no assumptions about the user and the structure of his theme. Block templates are still optional, hence they don't have to be used by default.
But it would make sense to encourage theme creators to make use of baseof.html since it removes a lot of redundancy. Creating a baseof.html when executing hugo new theme xyz might also help to increase its adaption.
If you think baseof.html should be created by default then label this issue as a feature request.
What remains is the question whether the adoption of block templates outweighs the assumptions of the users and his intended theme structure.
I agree with @juh2 that most would really want a baseof.html if they knew about it. But we should then set up a basic structure with a content section etc.
How about the addition of baseof.html, shortcodes, and img? Seems like content and data should stay independent of the theme scaffolding. Also, I'm not especially firm on img:
I would second the idea of including some partial calls as noted above by @digitalcraftsman. Simple enough to clue in new users and not so complicated that people end up deleting a bunch of scaffolding to get up and running...
@digitalcraftsman I think the header/footer is an antipattern that the baseof.html solves -- and we should fix that. In the example you give, neither the header nor the footer is well-formed HTML document that can easily be edited/formatted by an editor. The baseof.html should form a simple and well formed HTML document with closing tags.
@bep with my understanding of your comment you propose that baseof.html should contain the whole skeleton for a page, i.e. it "should form a simple and well formed HTML document with closing tags.".
Would a minimalistic baseof.html would look like this?
<html><head><title>Hugo</title><!-- some other stuff --></head><body><divid="content">
{{- block "main" . }}{{- end }}
</div><footer><!-- copyright etc. --></footer></body></html>
I see the inclusion of the header.html and footer.html in baseof.html as a composition of simple templates that form a larger and more complex one.
But it would make sense to encourage theme creators to make use of baseof.html since it removes a lot of redundancy. Creating a baseof.html when executing hugo new theme xyz might also help to increase its adaption.
Since everyone has come to a consensus, I think it would be interesting to implement it in hugo new theme and maybe even in hugo new site (in a new interactive mode) with more instruction and guidance to the person starting a new website or a new theme. With new theme especially, perhaps some guidance can ben written and some recommended licenses be offered...
Activity
digitalcraftsman commentedon Jun 10, 2017
Hello @juh2,
We make no assumptions about the user and the structure of his theme. Block templates are still optional, hence they don't have to be used by default.
But it would make sense to encourage theme creators to make use of
baseof.htmlsince it removes a lot of redundancy. Creating abaseof.htmlwhen executinghugo new theme xyzmight also help to increase its adaption.If you think
baseof.htmlshould be created by default then label this issue as a feature request.What remains is the question whether the adoption of block templates outweighs the assumptions of the users and his intended theme structure.
juh2 commentedon Jun 10, 2017
Thanks for the clarification.
I see no obvious button to label this issue as feature request.
Could someone with more insight or rights do this?
TIA
bep commentedon Jun 10, 2017
I agree with @juh2 that most would really want a
baseof.htmlif they knew about it. But we should then set up a basic structure with a content section etc.rdwatters commentedon Jun 10, 2017
Here's what is currently generated:
How about the addition of
baseof.html,shortcodes, andimg? Seems likecontentanddatashould stay independent of the theme scaffolding. Also, I'm not especially firm onimg:bep commentedon Jun 10, 2017
Let us keep this issue about ...
besof.htmland not add a lot of other issues on top.rdwatters commentedon Jun 10, 2017
You mentioned a
contentsection as well, so I was running with it. Is this in the "beginner" or "easy" category,@bep? Maybe I can give it a shot 😄digitalcraftsman commentedon Jun 11, 2017
The general tenor of the comments seems to supports this proposal. I would to extend this thought by linking the files together as follows:
Hugo generates
header.htmlandfooter.htmlby default. So thebaseof.htmlwould look like this:{{- partial "header.html" . -}} {{- block "main" . }}{{- end }} {{- partial "footer.html" . -}}404.html,list.html,single.htmlandindex.htmlwould consist ofrdwatters commentedon Jun 11, 2017
I would second the idea of including some partial calls as noted above by @digitalcraftsman. Simple enough to clue in new users and not so complicated that people end up deleting a bunch of scaffolding to get up and running...
bep commentedon Jun 11, 2017
@digitalcraftsman I think the header/footer is an antipattern that the
baseof.htmlsolves -- and we should fix that. In the example you give, neither the header nor the footer is well-formed HTML document that can easily be edited/formatted by an editor. Thebaseof.htmlshould form a simple and well formed HTML document with closing tags.digitalcraftsman commentedon Jun 11, 2017
@bep with my understanding of your comment you propose that
baseof.htmlshould contain the whole skeleton for a page, i.e. it "should form a simple and well formed HTML document with closing tags.".Would a minimalistic
baseof.htmlwould look like this?I see the inclusion of the
header.htmlandfooter.htmlinbaseof.htmlas a composition of simple templates that form a larger and more complex one.bep commentedon Jun 11, 2017
The partial pattern is still useful and should still be part of the scheleton, as long as the templates are well formed:
Or variants of the above. In the above, all templates are well formed (base + footer + partial).
digitalcraftsman commentedon Jun 11, 2017
Got it.
rdwatters commentedon Jun 11, 2017
If I may get more granular, I would only suggest that there be a
head.htmland aheader.htmlsincehead.htmltends to get very big very quickly:Anything more than this, though, and I'm probably just getting too opinionated 😄
bep commentedon Jun 11, 2017
@rdwatters sure, but in your example
head.htmlwould not be well formed on its own.4 remaining items
anthonyfok commentedon Jun 2, 2018
I got here from:
digitalcraftsman wrote:
Sounds like a great idea!
Both bep and rdwatters wrote:
Hohoho! Great minds think alike!
Since everyone has come to a consensus, I think it would be interesting to implement it in
hugo new themeand maybe even inhugo new site(in a new interactive mode) with more instruction and guidance to the person starting a new website or a new theme. With new theme especially, perhaps some guidance can ben written and some recommended licenses be offered...commands: Create _default/baseof.html in "new theme"
commands: Create _default/baseof.html in "new theme"
github-actions commentedon Mar 3, 2022
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.