I am going though Hugo by building a blog site and I am stuck at how layouts/_default/list.html
, layouts/_default/baseof.html
and layouts/taxonomy/tag.html
interact with each other.
EDIT: the whole site is available at https://gitlab.com/WoJ/blog
The structure of my site is the following:
Specifically, layouts/taxonomy/tag.html
is
Below is a list of pages with tag {{ .Page.Title }}
<ul>
{{ range .Data.Pages }}
<li>
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
This correctly gives me the expected bare page, with the line `Below is …" and a bullet list of posts.
So far so good
I then wanted to style it the way the other pages are. They are based on baseof.html
:
<!DOCTYPE html>
<html>
{{- partial "head.html" . -}}
<body id="site">
{{- partial "header.html" . -}}
<div id="content">
{{- block "main" . }}{{- end }}
</div>
{{- partial "footer.html" . -}}
</body>
</html>
In other pages (index.html
or _default/about.html
) I am just defining main
and that block gets merged with baseof.html
(at least this is my understanding and the result is as expected). For instance _default/about.html
is
{{ define "main" }}
<main aria-role="main">
{{ .Content }}
</main>
{{ end }}
I tried to do the same with layouts/taxonomy/tag.html
:
{{ define "main" }}
Below is a list of pages with tag {{ .Page.Title }}
<ul>
{{ range .Data.Pages }}
<li>
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</li>
{{ end }}
</ul>
{{ end }}
The result is an empty page:
<html>
<head></head>
<body></body>
</html>
What is the correct way to merge such list templates?
(I am not sure actually where _default/list.html
is in all of this - it seems it is not taken into account at all for the tags page above)