Fix nilpointer on ToC heading

Fixes #11843

Co-authored-by: Joe Mooring <joe.mooring@veriphor.com>
This commit is contained in:
Bjørn Erik Pedersen
2025-09-04 11:21:29 +02:00
parent b8eb45c9df
commit 4f2d2b2cc4
3 changed files with 33 additions and 0 deletions
@@ -121,3 +121,16 @@ CONTENT
b, _ = hugolib.TestE(t, files)
b.AssertLogMatches(`error calling ToHTML: startLevel: unable to cast "x" of type string`)
}
func TestHeadingsNilpointerIssue11843(t *testing.T) {
t.Parallel()
files := `
-- hugo.toml --
-- layouts/home.html --
{{ $h := index .Fragments.HeadingsMap "bad_id" }}
{{ if not $h }}OK{{ end }}
`
b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "OK")
}