`runtime error: index out of range` when list template defines a block

I’m at a loss here. I updated Hugo to 0.46-extended because I intend to try adding SASS support to my theme, but the update coincided with the introduction of a rendering error.

Building sites … ERROR 2018/08/09 18:44:05 Failed to render "_default/list.html": runtime error: index out of range
ERROR 2018/08/09 18:44:05 Stack Trace:
goroutine 206 [running]:
github.com/gohugoio/hugo/hugolib.stackTrace(0x4b0, 0x11027c7, 0x17)
        /go/src/github.com/gohugoio/hugo/hugolib/page.go:280 +0x76
github.com/gohugoio/hugo/hugolib.(*Site).renderForLayouts.func1(0xc420e618a0, 0xc42023a600)
        /go/src/github.com/gohugoio/hugo/hugolib/site.go:1742 +0x135
panic(0xfc9ee0, 0x19b6650)
        /usr/local/go/src/runtime/panic.go:502 +0x229
text/template.errRecover(0xc420e61790)
        /usr/local/go/src/text/template/exec.go:137 +0x1d4
panic(0xfc9ee0, 0x19b6650)
        /usr/local/go/src/runtime/panic.go:502 +0x229
text/template.errRecover(0xc420e60990)
        /usr/local/go/src/text/template/exec.go:137 +0x1d4
panic(0xfc9ee0, 0x19b6650)
        /usr/local/go/src/runtime/panic.go:502 +0x229
text/template.errRecover(0xc420e5fd28)
        /usr/local/go/src/text/template/exec.go:137 +0x1d4
panic(0xfc9ee0, 0x19b6650)
        /usr/local/go/src/runtime/panic.go:502 +0x229
text/template.errRecover(0xc420e5eb38)
        /usr/local/go/src/text/template/exec.go:137 +0x1d4
panic(0xfc9ee0, 0x19b6650)
        /usr/local/go/src/runtime/panic.go:502 +0x229
github.com/gohugoio/hugo/vendor/github.com/nicksnyder/go-i18n/i18n/language.newOperandsString(0x0, 0x0, 0x498518, 0x120, 0x1027a80)
        /go/src/github.com/gohugoi
Total in 317 ms
Error: Error building site: logged 2 error(s)

This occurs only when _default/list.html defines the "main_content" block, which is first declared in _default/baseof.html. If I remove the {{ define "main_content" }} and the corresponding {{ end }} while leaving the rest of the code in _default/list.html, rendering happens without errors (though I suppose it may not be rendering the list template anymore?).

On the other hand, having _default/list.html contain only {{ define "main_content" }}{{ end }} still causes the error. So I don’t think its my code that’s causing the error, but I’m not sure what else would be causing it.

Any help would be appreciated, as I’d like to get these updates published sooner rather than later. You can clone the website via

git clone --recursive https://git.shadow53.com/BluestNight/bluestnight.com.git

Development on the theme is on a develop branch, so if git tries to checkout the theme’s master for some reason, just checkout the develop branch. The website should be on its master branch.

Of course I figure it out right after posting for help.

I had an empty _index.md file. Apparently Hugo was trying to access the front-matter that wasn’t defined, and panicked.

1 Like