Closed dmitriid closed 7 years ago
Is there any idea why this might be happening?
Where in the documentation did you find the /layouts/gen (the name of your section, I assume) syntax?
In https://gohugo.io/templates/content/
/gen/
is a section of the website (see /content/gen
). In 0.18-DEV
hugo was correctly picking the layout for gen
from /themes/THEME/layouts/SECTION/
according to https://gohugo.io/templates/content/
And then it stopped for some reason.
I can give you access to the repository in the screenshot, if you want to try running this.
OK, I now see that the documentation is inconsistent about this, see
https://gohugo.io/templates/list/
So your syntax is correct for single templates, but not list, which does not make much sense. We will have to fix that.
But in the meantime, I would recommend sticking with this documentation re. the base templates:
https://gohugo.io/templates/blocks/
Moving your section template to
/layouts/section/gen-baseof.html
Should do the trick.
Thank you for your reply!
I'm still a bit confused with all the sections :)
/layouts/section/gen-baseof.html
list
template goes into /layouts/section/gen.html
?single
template goes into ?Because the following happened (MacOS, hugo v0.18.1):
New structure:
gen-baseof.html
{{ block "main" . }}
{{ end }}
single.html
{{ define "main" }}
{{ .Content }}
{{ end }}
The generated file for a single entry (accessible in browser from http://localhost:1313/gen/social/) still has the outer shell from _default/baseof.html
and _default/single.html
The generated file for "section list" (accessible in browser from http://localhost:1313/gen/) gets its outer shell from _default/baseof.html
and everything else from section/gen.html
I added some tests, and I cannot reproduce what you say in your last post.
Take this further on the discussion forum (start a new thread, and please post a reference to a full source repo that demonstrates your issue).
OK, my test was wrong ... There is a issue here, but I will have to look closer into it.
I will post a link to the repo where this can be reproduced later today. Thank you for looking into this!
Note:
If you add:
mysection/
baseof.html
list.html
single.html
This should now work as expected.
Also note that with:
_default/
single.html
baseof.html
mysection/
baseof.html
list.html
The single pages in /mysection will get the base template from _default.
Thanks! I'll try this out ASAP
Ok, tried it out. The error is still there for themes.
Full version (based on this project):
$ ~/.go/bin/hugo version
Hugo Static Site Generator v0.20-DEV darwin/amd64 BuildDate: 2017-03-03T11:49:53+01:00
$ ~/.go/bin/hugo server --buildDrafts --theme=freja -v
The following layout works:
layouts
is in the root directory of the projectlayouts/gen
The following doesn't work:
layouts
are a part of the theme:layouts/_default
I'll go with layouts
in the root directory for now, but it would be nice to have the same behaviour for themes, too
Awesome! Thanks!
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.
What's happening
(also see img below)
This happens on both
Hugo 0.18.1
andHugo 0.19-DEV
. Didn't happen onHugo 0.18-DEV
I have a theme, with default layouts defined as follows:
./themes/freja/layouts/_default/{baseof,list,single}.html
For the
gen
section of the website I've overriden all of them:./themes/freja/layouts/gen/{baseof,list,single}.html
And now the section's baseof template isn't used.
Screenshot of the file tree:
./themes/freja/layouts/_default/baseof.html
is a regular html file:whereas
./themes/freja/layouts/gen/baseof.html
is just a shell:The rest of the templates are quite similar.
The result for
/gen
should look like this: https://dmitriid.com/gen/social/ Now, however, the output is surrounded by HTML from the theme's defaultbaseof.html