New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hugo new theme does not create a baseof.html #3576

Closed
juh2 opened this Issue Jun 10, 2017 · 19 comments

Comments

Projects
None yet
5 participants
@juh2

juh2 commented Jun 10, 2017

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.

@digitalcraftsman

This comment has been minimized.

Show comment
Hide comment
@digitalcraftsman

digitalcraftsman Jun 10, 2017

Member

Hello @juh2,

Block-Templates are the new default I think

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.

Member

digitalcraftsman commented Jun 10, 2017

Hello @juh2,

Block-Templates are the new default I think

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.

@juh2

This comment has been minimized.

Show comment
Hide comment
@juh2

juh2 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

juh2 commented 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

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 10, 2017

Member

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.

Member

bep commented Jun 10, 2017

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.

@rdwatters

This comment has been minimized.

Show comment
Hide comment
@rdwatters

rdwatters Jun 10, 2017

Contributor

Here's what is currently generated:

.
├── LICENSE.md
├── archetypes
│   └── default.md
├── layouts
│   ├── 404.html
│   ├── _default
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   └── partials
│       ├── footer.html
│       └── header.html
├── static
│   ├── css
│   └── js
└── theme.toml

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:

.
├── LICENSE.md
├── archetypes
│   └── default.md
├── layouts
│   ├── 404.html
│   ├── _default
│   │   ├── baseof.html
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   ├── partials
│   │ ├── footer.html
│   │ └── header.html
│   └── shortcodes
├── static
│   ├── css
│   ├── img
│   └── js
└── theme.toml
Contributor

rdwatters commented Jun 10, 2017

Here's what is currently generated:

.
├── LICENSE.md
├── archetypes
│   └── default.md
├── layouts
│   ├── 404.html
│   ├── _default
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   └── partials
│       ├── footer.html
│       └── header.html
├── static
│   ├── css
│   └── js
└── theme.toml

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:

.
├── LICENSE.md
├── archetypes
│   └── default.md
├── layouts
│   ├── 404.html
│   ├── _default
│   │   ├── baseof.html
│   │   ├── list.html
│   │   └── single.html
│   ├── index.html
│   ├── partials
│   │ ├── footer.html
│   │ └── header.html
│   └── shortcodes
├── static
│   ├── css
│   ├── img
│   └── js
└── theme.toml
@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 10, 2017

Member

Let us keep this issue about ... besof.html and not add a lot of other issues on top.

Member

bep commented Jun 10, 2017

Let us keep this issue about ... besof.html and not add a lot of other issues on top.

@rdwatters

This comment has been minimized.

Show comment
Hide comment
@rdwatters

rdwatters Jun 10, 2017

Contributor

You mentioned a content section as well, so I was running with it. Is this in the "beginner" or "easy" category,@bep? Maybe I can give it a shot 😄

Contributor

rdwatters commented Jun 10, 2017

You mentioned a content section 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

This comment has been minimized.

Show comment
Hide comment
@digitalcraftsman

digitalcraftsman Jun 11, 2017

Member

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.html and footer.html by default. So the baseof.html would look like this:

{{- partial "header.html" . -}}

{{- block "main" . }}{{- end }}

{{- partial "footer.html" . -}}

404.html, list.html, single.html and index.html would consist of

{{- define "main" }}{{- end }}
Member

digitalcraftsman commented 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.html and footer.html by default. So the baseof.html would look like this:

{{- partial "header.html" . -}}

{{- block "main" . }}{{- end }}

{{- partial "footer.html" . -}}

404.html, list.html, single.html and index.html would consist of

{{- define "main" }}{{- end }}
@rdwatters

This comment has been minimized.

Show comment
Hide comment
@rdwatters

rdwatters Jun 11, 2017

Contributor

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...

Contributor

rdwatters commented 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

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 11, 2017

Member

@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.

Member

bep commented Jun 11, 2017

@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.

@digitalcraftsman

This comment has been minimized.

Show comment
Hide comment
@digitalcraftsman

digitalcraftsman Jun 11, 2017

Member

@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>
        <div id="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.

Member

digitalcraftsman commented Jun 11, 2017

@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>
        <div id="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.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 11, 2017

Member

The partial pattern is still useful and should still be part of the scheleton, as long as the templates are well formed:

<html>
    {{- partial "header.html" . -}}
    <body>
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>

Or variants of the above. In the above, all templates are well formed (base + footer + partial).

Member

bep commented 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:

<html>
    {{- partial "header.html" . -}}
    <body>
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>

Or variants of the above. In the above, all templates are well formed (base + footer + partial).

@digitalcraftsman

This comment has been minimized.

Show comment
Hide comment
@digitalcraftsman
Member

digitalcraftsman commented Jun 11, 2017

Got it.

@rdwatters

This comment has been minimized.

Show comment
Hide comment
@rdwatters

rdwatters Jun 11, 2017

Contributor

If I may get more granular, I would only suggest that there be a head.html and a header.html since head.html tends to get very big very quickly:

<html>
    <head>
    {{- partial "head.html" . -}}
    </head>
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>

Anything more than this, though, and I'm probably just getting too opinionated 😄

Contributor

rdwatters commented Jun 11, 2017

If I may get more granular, I would only suggest that there be a head.html and a header.html since head.html tends to get very big very quickly:

<html>
    <head>
    {{- partial "head.html" . -}}
    </head>
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>

Anything more than this, though, and I'm probably just getting too opinionated 😄

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 11, 2017

Member

@rdwatters sure, but in your example head.html would not be well formed on its own.

Member

bep commented Jun 11, 2017

@rdwatters sure, but in your example head.html would not be well formed on its own.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 11, 2017

Member

This would be a good start:

<html>
    {{- partial "head.html" . -}}
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>
Member

bep commented Jun 11, 2017

This would be a good start:

<html>
    {{- partial "head.html" . -}}
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>
@rdwatters

This comment has been minimized.

Show comment
Hide comment
@rdwatters

rdwatters Jun 11, 2017

Contributor

How about...

<html>
    {{- partial "head.html" . -}}
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>
Contributor

rdwatters commented Jun 11, 2017

How about...

<html>
    {{- partial "head.html" . -}}
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>
@rdwatters

This comment has been minimized.

Show comment
Hide comment
@rdwatters

rdwatters Jun 11, 2017

Contributor

And we crossed streams. Oops.

Contributor

rdwatters commented Jun 11, 2017

And we crossed streams. Oops.

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Dec 6, 2017

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.

stale bot commented Dec 6, 2017

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.

@stale stale bot added the Stale label Dec 6, 2017

@stale stale bot closed this Dec 27, 2017

@anthonyfok anthonyfok reopened this Jun 2, 2018

@stale stale bot removed the Stale label Jun 2, 2018

@anthonyfok

This comment has been minimized.

Show comment
Hide comment
@anthonyfok

anthonyfok Jun 2, 2018

Contributor

I got here from:

  1. #4808
  2. https://discourse.gohugo.io/t/what-are-the-pros-cons-of-using-a-baseof-template-or-the-standard-template/8048/4
  3. #3576 (comment)

digitalcraftsman wrote:

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.

Sounds like a great idea!

Both bep and rdwatters wrote:

<html>
    {{- partial "head.html" . -}}
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>

Hohoho! Great minds think alike!

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...

Contributor

anthonyfok commented Jun 2, 2018

I got here from:

  1. #4808
  2. https://discourse.gohugo.io/t/what-are-the-pros-cons-of-using-a-baseof-template-or-the-standard-template/8048/4
  3. #3576 (comment)

digitalcraftsman wrote:

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.

Sounds like a great idea!

Both bep and rdwatters wrote:

<html>
    {{- partial "head.html" . -}}
    <body>
        {{- partial "header.html" . -}}
        <div id="content">
        {{- block "main" . }}{{- end }}
        </div>
        {{- partial "footer.html" . -}}
    </body>
</html>

Hohoho! Great minds think alike!

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...

@anthonyfok anthonyfok self-assigned this Jun 2, 2018

@anthonyfok anthonyfok added the Keep label Jun 5, 2018

anthonyfok added a commit to anthonyfok/hugo that referenced this issue Jun 11, 2018

commands: Create _default/baseof.html in "new theme"
Thanks to @digitalcraftsman, @bep and @rdwatters for providing the
actual content of the default baseof.html file.

Fixes #3576

@bep bep closed this in #4840 Jun 11, 2018

bep added a commit that referenced this issue Jun 11, 2018

commands: Create _default/baseof.html in "new theme"
Thanks to @digitalcraftsman, @bep and @rdwatters for providing the
actual content of the default baseof.html file.

Fixes #3576

@bep bep added this to the v0.42 milestone Jun 11, 2018

@bep bep removed the Proposal label Jun 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment