Error: Warning for missing template that does exist

Running Hugo 0.51 (which nicely outputs these warnings now), I notice a warning for template missing for a custom output type, yet, I already have _default/single.html in my layouts folder. If I create one of the other templates on the list, there is no error.

WARN 2018/11/13 18:54:15 Found no layout for "page", language "en", output format "archives": create a template below /layouts with one of these filenames: 

section-name/single.en.archives.html, 
section-name/single.archives.html, 
section-name/single.en.html, 
section-name/single.html, 
_default/single.en.archives.html, 
_default/single.archives.html, 
_default/single.en.html, 
_default/single.html

I can work up an example if necessary, just thought I might be missing something obvious.

If you end up creating an example, I’ll see if I can reproduce.

Hi all

I think I have similiar issue like budparr. The warning appears in my command line but no errors in browser and Hugo still render fine both hugo --server and hugo

my env

version go1.11 windows/amd64
Static Site Generator v0.51/extended windows/amd64 BuildDate: unknown

the warning

Building sites … WARN 2018/11/14 11:06:31 Found no layout for "section", language "en", output format "HTML": create a template below /layouts with one of these filenames: uploads/uploads.en.html.html, 
uploads/section.en.html.html, 
uploads/list.en.html.html, 
uploads/uploads.html.html, 
uploads/section.html.html, 
uploads/list.html.html, 
uploads/uploads.en.html, 
uploads/section.en.html, 
uploads/list.en.html, 
uploads/uploads.html, 
uploads/section.html, 
uploads/list.html, 
section/uploads.en.html.html, 
section/section.en.html.html, 
section/list.en.html.html, 
section/uploads.html.html, 
section/section.html.html, 
section/list.html.html, 
section/uploads.en.html, 
section/section.en.html, section/list.en.html, 
section/uploads.html, 
section/section.html, 
section/list.html, _default/uploads.en.html.html,
 _default/section.en.html.html, 
_default/list.en.html.html, 
_default/uploads.html.html, 
_default/section.html.html, 
_default/list.html.html, 
_default/uploads.en.html, 
_default/section.en.html, 
_default/list.en.html,
 _default/uploads.html, 
_default/section.html, 
_default/list.html
WARN 2018/11/14 11:06:31 Found no layout for "section", language "en", output format "HTML": create a template below /layouts with one of these filenames: 
pages/pages.en.html.html, 
pages/section.en.html.html, 
pages/list.en.html.html, 
pages/pages.html.html, 
pages/section.html.html, 
pages/list.html.html, 
pages/pages.en.html, 
pages/section.en.html, 
pages/list.en.html, 
pages/pages.html, 
pages/section.html, 
pages/list.html, 
section/pages.en.html.html, 
section/section.en.html.html, 
section/list.en.html.html, 
section/pages.html.html, 
section/section.html.html, 
section/list.html.html, section/pages.en.html, 
section/section.en.html, 
section/list.en.html, section/pages.html, 
section/section.html, 
section/list.html, 
_default/pages.en.html.html, 
_default/section.en.html.html, 
_default/list.en.html.html,
_default/pages.html.html,
_default/section.html.html, 
_default/list.html.html, 
_default/pages.en.html, 
_default/section.en.html, 
_default/list.en.html, 
_default/pages.html, 
_default/section.html, 
_default/list.html

Just tested this on one of my projects, and am getting the same warning.

My hugo version is 0.51

My layout:

layouts/
    index.html
    _default/
        baseof.html
        single.html

Edit: Looking at this warning some more, it makes sense in my case, as I don’t have a list template. Adding a layouts/_default/list.html makes it go away.

The obvious would be in your project, which we don’t see.

Also note that the WARNINGs are not new (I adjusted the error message), it’s just that they earlier was more … hidden.

I believe that the behavior is expected (though not by me), but the warning does not appear to be correct, or they may be related.

  1. When you create a Custom Output Type, Hugo looks for a template for that output type. Typically, I’m creating an output type for a specific section or sections, not as a default for all sections. Hugo wants a template for the COT in the _default folder, even if you have a template for it in a section folder.

I think this creates unnecessary output.

  1. The warning states that—as you can see from my original post—that it’s looking for, at least, _default/single.html but the existence of a template with that name does not appear to be sufficient to avoid the warning.

I think this warning is incorrect.

Here is a repo to demonstrate the behavior. It’s current state is with the _default/single.archives.html template not present (I manipulated the name so it can be added back in).

FWIW, I like the warnings, thank you.

I also have a bunch of these warnings. I noticed the newly improved message, which is more informative, but I am afraid I still don’t get what’s going on, from my ignorance.

The warning I’m getting are like this (but this is only a sample):

WARN 2019/01/15 11:28:45 
 Found no layout for "section"
 language "en"
 output format "JSON": create a template below /layouts with one of these filenames: admin/admin.en.json.json
 admin/section.en.json.json
 admin/list.en.json.json
 admin/admin.json.json
 admin/section.json.json
 admin/list.json.json
 admin/admin.en.json
 admin/section.en.json
 admin/list.en.json
 admin/admin.json
 admin/section.json
 admin/list.json
 section/admin.en.json.json
 section/section.en.json.json
 section/list.en.json.json
 section/admin.json.json
 section/section.json.json
 section/list.json.json
 section/admin.en.json
 section/section.en.json
 section/list.en.json
 section/admin.json
 section/section.json
 section/list.json
 _default/admin.en.json.json
 _default/section.en.json.json
 _default/list.en.json.json
 _default/admin.json.json
 _default/section.json.json
 _default/list.json.json
 _default/admin.en.json
 _default/section.en.json
 _default/list.en.json
 _default/admin.json
 _default/section.json
 _default/list.json
WARN 2019/01/15 11:28:45 
 Found no layout for "section"
 language "en"
 output format "JSON": create a template below /layouts with one of these filenames: community/community.en.json.json
 community/section.en.json.json
 community/list.en.json.json
 community/community.json.json
 community/section.json.json
 community/list.json.json
 community/community.en.json
 community/section.en.json
 community/list.en.json
 community/community.json
 community/section.json
 community/list.json
 section/community.en.json.json
 section/section.en.json.json
 section/list.en.json.json
 section/community.json.json
 section/section.json.json
 section/list.json.json
 section/community.en.json
 section/section.en.json
 section/list.en.json
 section/community.json
 section/section.json
 section/list.json
 _default/community.en.json.json
 _default/section.en.json.json
 _default/list.en.json.json
 _default/community.json.json
 _default/section.json.json
 _default/list.json.json
 _default/community.en.json
 _default/section.en.json
 _default/list.en.json
 _default/community.json
 _default/section.json
 _default/list.json

(commas are replaced with line breaks, for clarity).

I would love to understand this a bit better, but more than anything I’d like to know the simplest way to fix this and get rid of the warnings - they are many, very verbose, and end up hiding more relevant messages. Thanks in advance for any help.

My project: https://github.com/salesagility/SuiteDocs/
(requires Asciidoctor to build)

The warning is here to tell you an output format is assigned to a page kind but no template file is provided for this Kind + Output combination.

In this project JSON output is assigned to your page of Kind section on your configuration:

section = [ "HTML", "RSS", "JSON"]

Yet you only have a JSON template file for the homepage (/index.json) and none for the sections.

Simply create a /_default/list.json template or remove the JSON output from your sections.

2 Likes

Hi regis, thanks for helping out.

So is there a benefit of using the JSON “kind” for a Docs site like mine? I guess it was there in my theme and I just used it without considering if I need it… :thinking:

So is there a benefit of using the JSON “kind” for a Docs site like mine?

Hugo terminology 101: JSON is not a Kind, JSON is an output format. Section, Homepage, those are Kinds (of pages).

Now answering your question is Hard for me, you should ask the theme owner. But I can see you have a search though, maybe it’s using it.

I can read your JSON output here: https://docs.suitecrm.com/index.json

Ok, let’s say I keep it. It does look potentially useful…

Is there a simple layout I can use just to stop the warning, copy it from somewhere else?

I mean, I don’t know what needs to be included in the layout, if you can point me to an example of what other people use I might take a stab at this.

Thanks once again for your help, much appreciated.

You can keep it on the homepage for which you have a template file. But on the sections, it is not produced as you don’t have a template file (hence the warning). So no chance something or someone is currenlty using your section’s JSON.

Therefor you can safely remove the JSON output from your sections by editing this line in your config.toml: https://github.com/salesagility/SuiteDocs/blob/master/config.toml#L23

1 Like

Sweet. Such a simple change and the message is gone :tada:. The site seems to be working just fine - including Search.

Thank you so much :+1:

Please make sure all the JSON data are valid, use these tool, which may help to validate JSON. if valid is not JSON, it will throw an error while parsing.