Using block templates inside a section?

I have a section defined in my site called blog. I am starting to make heavy use of block templates, and they are working everywhere else.

However, this snippet of code doesn’t render any text when I load http://localhost:1313/blog/:

{{- define "main" -}}

<div class="row">
  <div class="col-md-12">
    <h1>Blog Posts</h1>
    <div>
      {{ range .Paginator.Pages }}
         {{ .Render "summary"}}
      {{ end }}
      {{ partial "blog_pagination.html" . }}
    </div>
  </div>
</div>

{{- end -}}

But this does:



<div class="row">
  <div class="col-md-12">
    <h1>Blog Posts</h1>
    <div>
      {{ range .Paginator.Pages }}
         {{ .Render "summary"}}
      {{ end }}
      {{ partial "blog_pagination.html" . }}
    </div>
  </div>
</div>

Two things:

  1. See https://github.com/spf13/hugo/issues/2549
    Without that fix, “heavy use of block templates” is not possible
  2. Your example is a classic example of “missing context” / showing too little. It is impossible to look at your examples and guess what’s wrong (a define is useless without a block, for starters)

I’m on v0.18 of Hugo (although I’ll check that issue to see if it was fixed in the build i have, which was a few days ago).

I’ll add more context later; I do apologize. The pages/templates outside of this one are working fine with the same block calls (although I know that might not mean anything).

For quick context, this is the “baseof” template that I think should be calling it:

OK, after typing in all my example code here, I figured out the problem:

The block {{- define "main" -}} cannot have the dashes which prevent the template from rendering the line. I removed them and it works fine. Sigh.