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

error instead of quiet logging when no layout can be found #1313

Closed
jmhodges opened this issue Aug 2, 2015 · 7 comments
Closed

error instead of quiet logging when no layout can be found #1313

jmhodges opened this issue Aug 2, 2015 · 7 comments

Comments

@jmhodges
Copy link
Contributor

jmhodges commented Aug 2, 2015

Was porting my site from jekyll to hugo, and hadn't written a layout for my posts section yet when I copied over my articles. Hugo silently elides pages without a layout instead of erroring vocally or exiting early. My site "worked" but had no pages in it.

It would be nice for it to error out and make a lot of noise (or, at least, make a lot of noise) when it can't find a layout.

Relevant code is in hugolib/site.go.

@jmhodges
Copy link
Contributor Author

jmhodges commented Aug 2, 2015

(I eventually happened on --log and dug into the log file, but I could see how folks wouldn't get that far.)

egonSchiele added a commit to egonSchiele/hugo that referenced this issue Mar 18, 2016
@bep bep closed this as completed in b159340 Jul 13, 2016
@bep bep reopened this Jul 14, 2016
bep added a commit that referenced this issue Jul 14, 2016
We have to figure out another way. There are perfectly valid reasons not having a layout for a page (I have have some broken sites as result of this).

See #1313

This reverts commit b159340.
@lebarde
Copy link
Contributor

lebarde commented Oct 9, 2016

  1. I don't know how to reproduce that because when I don't set any layout this throws no warning.
  2. A workaround would be to throw an error, but to say that you can set a AllowEmptyLayout variable in the config, if you really want this. I don't see how to manage that without one more variable if it is useful for some people not to have any layout defined.

We could have something like this:

// in hugolib/site.go :
func (s *Site) renderForLayouts(name string, d interface{}, w io.Writer, layouts ...string) error {
    layout, found := s.findFirstLayout(layouts...)
    // user have to define a layout, unless params.AllowEmptyLayout is set to true.
    if found == false && viper.GetBool("AllowEmptyLayout") == false {
        jww.ERROR.Printf("Unable to locate layout for %s: %s. Please set a layout or AllowEmptyLayout to true in your config file if you really want this.\n", name, layouts)
        return nil
    }

    if err := s.renderThing(d, layout, w); err != nil {
[…]

@bep
Copy link
Member

bep commented Oct 9, 2016

  • There is currently WARNING logging when a layout is missing
  • I merged a patch that upped this to ERROR
  • Then the CI build for the Hugo docs failed because of missing 404.html template
  • So I added a 404.html template ...
  • But then a lot of the themes on the themes site started to fail ...
  • So I reverted the change to avoid havoc in the wild

So any fix to this must have some sense of what templates are vital to render a site:

  • A template for page
  • A template for home page
  • more? I think the above should cover the important stuff and help people in this thread.

@lebarde
Copy link
Contributor

lebarde commented Oct 11, 2016

Thank you for your explanation. But maybe that WARN message is acceptable?

@tj
Copy link

tj commented Mar 6, 2017

👍 I have -v and --log enabled and I get no error or warning for blank pages that are rendered. It would be really helpful to see a list what Hugo is trying to resolve to in order to grok Hugo a bit better.

tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
We have to figure out another way. There are perfectly valid reasons not having a layout for a page (I have have some broken sites as result of this).

See gohugoio#1313

This reverts commit b159340.
@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
@github-actions
Copy link

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 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants