BennX
January 12, 2019, 11:58am
1
Hey Hugo Community
One of my list Template is not picking up the .Pages and i wonder why.
I assume I broke something of the template lookup order but i can’t figure it out.
Since the project is a bit bigger I’ll try to explain it here but I think the best way is to have a look at the project itself (working branch contains the “broken” templates):
Content: https://gitlab.com/BennX/sulco.de/tree/working/content/vermehrung
Layouts: https://gitlab.com/BennX/sulco.de/tree/working/layouts
Folder Structure:
content
- vermehrung
-- _index..md
-- page0.md
layouts
- vermehrung
-- list.html
The Layout template:
<!DOCTYPE html>
<html>
<body>
<main role="main" class="container">
<h1>{{.Title}}</h1>
<div class="row">
{{ range .Pages }}
<div class="col-md">
<div class="row m-0 justify-content-center">
<a class="btn btn-primary my-3" href="{{ .Permalink }}" role="button">{{ .Title }}</a>
</div>
</div>
{{ end }}
</div>
{{ .Content }}
</main>
</body>
</html>
_index.md
---
title: Vermehrung
description: conent description
menu:
main:
name: Vermehrung
weight: 3
author: Me
---
content
It’s picking up the custom layout fomr layouts/vermehrung/list.html but the layout doesn’t render the .Pages in.
What did I do wrong with the layouts and the Template lookup order?
Thank you very for your time to read this and hopefully for your help,
BennX
BennX
January 12, 2019, 10:58pm
3
Actually it doesn’t really help.
The lookup order seem to be just fine but it still doesn’t render properly.
Looks like it’s not picking up the sub pages at all no matter what I do. But they are in .Site.Pages
Perhaps it is because of your list template layouts/_default/list.html
only has {{ .Content }}
in it and is identical to your layouts/_default/single.html
. Didn’t find another list template in your project.
Cloned your repo and it doesn’t show what you reference above.
Ah, I see. The repo seems to clone the master
branch because it’s set up that way. Try it again later with working
branch. Sorry.
BennX
January 13, 2019, 9:08am
6
Hey Leo. Thank’s for investigating!
Quick note about building the project, which i should have said earlier:
You’ll need NPM and run npm install
within the project.
NPM Is used to compile the bootstrap with my configuration, adding a react gallery component to one of the static sites and optimizing the website.
Build it with npm run build
.
Local server with npm start
Done. But something seems to be wrong with the repo (see attached screenshot). The layout directory does not show what you’re referencing.
BennX
January 13, 2019, 10:46am
8
BennX
January 13, 2019, 10:52am
9
The vermehrung/list.html Template:
<!DOCTYPE html>
<html>
{{- partial "head.html" . -}}
<body>
{{- partial "navigation.html" . }}
<main role="main" class="container">
<h1>{{.Title}}</h1>
<div class="row">
{{ range .Pages }}
<div class="col-md">
<div class="row m-0">
<img class="card-img-top" data-src="holder.js/100px225?theme=thumb&bg=55595c&fg=eceeef&text=Thumbnail" alt="Thumbnail [100%x225]" style="height: 225px; width: 100%; display: block;" src="data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%22436%22%20height%3D%22225%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20436%20225%22%20preserveAspectRatio%3D%22none%22%3E%3Cdefs%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E%23holder_16841a3c290%20text%20%7B%20fill%3A%23eceeef%3Bfont-weight%3Abold%3Bfont-family%3AArial%2C%20Helvetica%2C%20Open%20Sans%2C%20sans-serif%2C%20monospace%3Bfont-size%3A22pt%20%7D%20%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22holder_16841a3c290%22%3E%3Crect%20width%3D%22436%22%20height%3D%22225%22%20fill%3D%22%2355595c%22%3E%3C%2Frect%3E%3Cg%3E%3Ctext%20x%3D%22143.8671875%22%20y%3D%22122.25%22%3EThumbnail%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E" data-holder-rendered="true">
</div>
<div class="row m-0 shadow p-3">
<p>{{ .Params.short }}</p>
</div>
<div class="row m-0 justify-content-center">
<a class="btn btn-primary my-3" href="{{ .Permalink }}" role="button">{{ .Title }}</a>
</div>
</div>
{{ end }}
</div>
{{ .Content }}
{{- partial "obligeds.html" . }}
</main>
{{- if isset .Params "footer" -}}
{{- partial "footer.html" . -}}
{{- end }}
</body>
{{- partial "lightbox.html" . -}}
</html>
Okay. Have to leave for the afternoon. But here’s a link to one of my Hugo test projects. Perhaps that can give you some ideas. The list template in there has
<div class="container">
<div class="">
{{ range .Data.Pages }}
<div class="">
<div class="card">
{{ partial "blog/summary.html" . }}
</div>
</div>
{{ end }}
</div>
</div>
The link (public project, actual branch ‘bootstrap’): https://gitlab.com/lego2018/hugo-template-example-project.git
BennX
January 13, 2019, 11:05am
11
Thanks again!
I’m seeing that from the lookup order he does pick the right template first. (vermehrung/list.html)
DEBUG 2019/01/13 11:59:35 Render section to "/vermehrung/index.html" with layouts ["vermehrung/vermehrung.en.html.html" "vermehrung/section.en.html.html" "vermehrung/list.en.html.html" "vermehrung/vermehrung.html.html" "vermehrung/section.html.html" "vermehrung/list.html.html" "vermehrung/vermehrung.en.html" "vermehrung/section.en.html" "vermehrung/list.en.html" "vermehrung/vermehrung.html" "vermehrung/section.html" "vermehrung/list.html" "section/vermehrung.en.html.html" "section/section.en.html.html" "section/list.en.html.html" "section/vermehrung.html.html" "section/section.html.html" "section/list.html.html" "section/vermehrung.en.html" "section/section.en.html" "section/list.en.html" "section/vermehrung.html" "section/section.html" "section/list.html" "_default/vermehrung.en.html.html" "_default/section.en.html.html" "_default/list.en.html.html" "_default/vermehrung.html.html" "_default/section.html.html" "_default/list.html.html" "_default/vermehrung.en.html" "_default/section.en.html" "_default/list.en.html" "_default/vermehrung.html" "_default/section.html" "_default/list.html"]
But, it seems like the .Data.Page or the .Page doesn’t contain the pages within the folder.
They are rendered with the right template _default/single.html
as PAGE into the folder public/vermehrung/page0/index.html
.
DEBUG 2019/01/13 12:00:46 Render page to "/vermehrung/vermehrung-0/index.html" with layouts ["vermehrung/single.en.html.html" "vermehrung/single.html.html" "vermehrung/single.en.html" "vermehrung/single.html" "_default/single.en.html.html" "_default/single.html.html" "_default/single.en.html" "_default/single.html"]
It is even rendering the index.xml with the right content of the subpages.
So why is the .Pages or .Data.Pages not filled with anything?
Hi,
In your config.yaml file:
taxonomies:
tag: ""
group: ""
category: ""
try deleting this section.
BennX
January 13, 2019, 11:31am
13
Thanks for trying to help!
I removed the group line:
pointyfar:
group: “”
Sadly it didn’t change anything of the result.
BennX
January 13, 2019, 11:36am
14
pointyfar:
Hi,
In your config.yaml file:
taxonomies:
tag: ""
group: ""
category: ""
try deleting this section.
Oh my fault!
I removed the whole Taxanomies section and it magically works.
Can someone explain why this ruined my layout and resulted in different renderings on startup or not including the subpages at all?
Here’s one of my gists which explains the different variables for pages. Possibly this helps.
BennX
January 13, 2019, 12:11pm
17
This is excatly what happend!
I recognized I couldn’t disable any of the taxanomies without breaking the layout. So I had to remove the whole part.
Everybody Thanks again!
You can disable taxonomies by setting disableKinds
: Taxonomies | Hugo
BennX
January 13, 2019, 1:17pm
19
Thanks again. This worked out. I also deactivated the RSS.