So I think I’m going nuts over here. I’m new to Hugo and I’m trying to create a theme for my website. Since I like the DRY principle I’m trying to use block templates and this is where I start going insane…
At the moment my theme has an index.html that pulls in a few partial templates but it is otherwise static. This page works and has always worked. Then I try to create stuff for the subpages…
My content structure:
content
|-member
|--_index.md
|-about
|--_index.md
|--style.md
|-contact.md
The layouts folder in my theme looks like this:
layouts
|-_default
|--baseof.html
|--list.html
|--single.html
My baseof.html looks like this (copy-pasted from the Hugo docs):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ block "title" . }}
<!-- Blocks may include default content. -->
{{ .Site.Title }}
{{ end }}</title>
</head>
<body>
<!-- Code that all your templates share, like a header -->
{{ block "main" . }}
<!-- The part of the page that begins to differ between templates -->
{{ end }}
<!-- More shared code, perhaps a footer -->
</body>
</html>
My list.html looks like this:
<!-- Note the lack of Go's context "dot" when defining blocks -->
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ range .Data.Pages }}
<h2>{{ .Title }}</h2>
<article>
{{ .Content }}
</article>
{{ end }}
{{ end }}
And finally single.html looks like this:
{{ define "title" }}
{{ .Title }} – {{ .Site.Title }}
{{ end }}
{{ define "main" }}
<h1>{{ .Title }}</h1>
{{ .Content }}
{{ end }}
The result from this is that Hugo renders contact.md and about\style.md to working pages. about\_index.md and member\_index.md are just blank pages with no content in them at all. If I remove the block definitions in list.html it will render the contents (obviously without any styling), but it doesn’t seem to show the actual contents of_index.md as I would expect. (I can’t for example just have {{ .Content }} and remove the iteration over .Data.Pages then the pages becomes almost empty again (it only shows .Title but not even the correct one at that).
Can anyone help shed any light on what’s wrong or what I am doing wrong or any hints at alla.
I am using Windows 10 Pro x64 with latest stable Hugo (as far as I know):
Hugo Static Site Generator v0.18.1 BuildDate: 2016-12-30T10:03:28+01:00