Errors with "type template.HTML should be string" with hugo 0.16.0

When I attempt to build our (working on 0.15) site, I get a slew of errors similar to this one:

ERROR: 2016/06/06 11:07:23 general.go:222: Error while rendering page events/2016-amsterdam/ template: theme/speakers/single.html:14:25: executing "theme/speakers/single.html" at <index .Site.Data.spe...>: error calling index: value has type template.HTML; should be string

For reference, the file is basically blank (it calls a template based upon the type):

date = "2016-03-06T21:17:14-06:00"
heading = "devopsdays Amsterdam - Speakers"
title = "speakers"
type = "speakers"


And this is the template it is using:

{{ partial "event_header.html" . }}

{{ $path := split $.Source.File.Path "/" }}
{{ $event_slug := index $path 1 }}
{{ $e :=  (index $ $event_slug) }}
<!-- end event header partial -->
      {{ .Content }}

 <!-- speaker page code begin -->

  {{ range $fname, $s := index .Site.Data.speakers (chomp $e.year) (lower $ }}
<div class="row">
    <div class="col-md-3">
        <img alt = "{{ $ }}" src = "/events/{{ $event_slug }}/speakers/{{$fname}}.jpg" class="img-responsive" width = "250px">
    <div class= "col-md-8">
       <h3><a href="/events/{{ $event_slug }}/program/{{$fname}}">{{ $ }}</a></h3>
       {{ if $s.twitter }} <a href="{{ $s.twitter }}">@{{ $s.twitter }}</a><br>{{ end }}
     {{ $ | markdownify }}

  {{ end }}

<!-- speaker code end -->

</div> <!-- closes the col-md-8 div from event_header -->
{{ partial "sponsors.html" . }}
</div> <!-- closes the row div -->

{{ partial "footer.html" . }}

Curious. Is this a public site on GitHub? (that I can clone and test)

I’m a dummy. I thought I had put the link to the repo here (but I was confusing myself with the ulimit issue I had on GH).

The repo is public at

We get slightly different output from hugo -v than from hugo server -w. Here are two gists with the output:

hugo server -w output

hugo -v output

OK, this is my mistake … At one point during the 0.16 release the chomp method’s return value got changed to template.HTML … Which index, surprisingly enough, does not handle …

Your workaround is to wrap it in a string func:

(string (chomp $e.year))

I will create an issue about chomp vs index.

That did it! Thanks!

Edit: It’s not backwards compatible with 0.15 though; when I build the site with 0.15 I get:

ERROR: 2016/06/06 Error while rendering page events/2016-amsterdam/ html/template: "theme/speakers/single.html" is an incomplete template

We’ll have to hold off on this merge until all of our contributors are on 0.16 I suppose :slight_smile:

You can use print to get it backwards compatible:

(print (chomp $e.year))

Tada! That did it. Thanks again. You rock.

Also see