Skip to content
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 · 20 comments · Fixed by #4840
Closed

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

juh2 opened this issue Jun 10, 2017 · 20 comments · Fixed by #4840
Assignees
Milestone

Comments

@juh2
Copy link

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
Copy link
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
Copy link
Author

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
Copy link
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
Copy link
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

@bep
Copy link
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
Copy link
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 😄

@digitalcraftsman
Copy link
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
Copy link
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...

@bep
Copy link
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
Copy link
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.

@bep
Copy link
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
Copy link
Member

Got it.

@rdwatters
Copy link
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
Copy link
Member

bep commented Jun 11, 2017

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

@bep
Copy link
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
Copy link
Contributor

How about...

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

@rdwatters
Copy link
Contributor

And we crossed streams. Oops.

@stale
Copy link

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 as completed Dec 27, 2017
@anthonyfok anthonyfok reopened this Jun 2, 2018
@stale stale bot removed the Stale label Jun 2, 2018
@anthonyfok
Copy link
Member

anthonyfok commented Jun 2, 2018

I got here from:

  1. baseof.html not used unless its executable in Debian #4808
  2. https://discourse.gohugo.io/t/what-are-the-pros-cons-of-using-a-baseof-template-or-the-standard-template/8048/4
  3. hugo new theme does not create a baseof.html #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
Thanks to @digitalcraftsman, @bep and @rdwatters for providing the
actual content of the default baseof.html file.

Fixes gohugoio#3576
@bep bep closed this as completed in #4840 Jun 11, 2018
bep pushed a commit that referenced this issue Jun 11, 2018
Thanks to @digitalcraftsman, @bep and @rdwatters for providing the
actual content of the default baseof.html file.

Fixes #3576
@github-actions
Copy link

github-actions bot commented 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants