Repository: gohugoio/hugo (language: go)

Issue:
hugo-coder theme no longer builds on 0.144.0 - "interface conversion: interface {} is nil, not []uint8"
The following code is present in the hugo-coder template at head:

`<meta name="description" content="{{ .Description | default (.Summary | default .Site.Params.description ) }}">`

In version `hugo v0.143.1-0270364a347b2ece97e0321782b21904db515ecc+extended linux/amd64 BuildDate=2025-02-04T08:57:38Z VendorInfo=gohugoio` the hugo-coder exampleSite builds successfully.  (https://github.com/simonhollingshead/hugo-coder/actions/runs/13362095239)

In version `hugo v0.144.0-b289b17c433aa8ebf8c73ebbaf4bed973ac8e4d5+extended linux/amd64 BuildDate=2025-02-17T16:22:31Z VendorInfo=gohugoio` this now fails (https://github.com/simonhollingshead/hugo-coder/actions/runs/13382377851) with the error

```
Error: error building site: render: failed to render pages: render of
"/home/runner/work/hugo-coder/hugo-coder/exampleSite/content/posts/more-rich-content.md" failed:
"/home/runner/work/hugo-coder/hugo-coder/layouts/_default/baseof.html:6:5": execute of template failed:
template: posts/single.html:6:5: executing "posts/single.html" at <partial "head.html" .>: error calling partial:
"/home/runner/work/hugo-coder/hugo-coder/layouts/partials/head.html:1:3": execute of template failed:
template: partials/head.html:1:3: executing "partials/head.html" at <partial "head/meta-tags.html" .>:
error calling partial: "/home/runner/work/hugo-coder/hugo-coder/layouts/partials/head/meta-tags.html:11:61":
execute of template failed: template: partials/head/meta-tags.html:11:61: executing
"partials/head/meta-tags.html" at <.Summary>: error calling Summary: interface conversion: interface {} is nil, not []uint8
```

I see nothing in the release notes indicating a breakage would be expected in this release, and this was not something that generated a warning in prior releases either.  While I'm absolutely not ruling out the possibility that the code in the template is wrong, I was not expecting the permissiveness of the parser to handle it to change given the release notes as shown.


### What version of Hugo are you using (`hugo version`)?

hugo v0.144.0-b289b17c433aa8ebf8c73ebbaf4bed973ac8e4d5+extended linux/amd64 BuildDate=2025-02-17T16:22:31Z VendorInfo=gohugoio

### Does this issue reproduce with the latest release?

This is the latest release.  The breakage appears to have occurred between 0.143.1 and 0.144.0.


Discussion / hints:
I have the same build error over at https://github.com/mabster/mabster.github.io
It's worth noting that I tried removing the reference to ".Summary" from the meta-tags.html file, and a subsequent build threw the same "interface conversion" error when it hit a reference to ".Content" in a different file. Both of those are, I believe, built into Hugo rather than anything specific to the theme.
Yes, this is a bug.

@mabster On your site, the problem is triggered by the line below in `content/posts/_index.md`:

```text
# <a class="float-right" style="margin-top: -2.4em" href="/index.xml" aria-label="Blog Feed"><i class="fa fa-rss"></i></a>
```

The `h1` element has no text value, which I guess is unexpected. For example, if you place an "x" before the closing `</a>` tag the problem goes away.
@jmooring Wow! Thanks for that. Weird though - the H1 does have content - it's the `<i>` element to render the RSS icon. I'll see if I can use a zero-width space or something.
@mabster None of the HTML elements have inner content. The icon rendering is a CSS thing.
@simonhollingshead How do I reproduce the problem with your site? I did this:

```text
git clone --recurse-submodules https://github.com/simonhollingshead/hugo-coder
cd hugo-coder/ 
hugo
```

And got this:

```text
Start building sites … 
hugo v0.144.0-b289b17c433aa8ebf8c73ebbaf4bed973ac8e4d5+extended linux/amd64 BuildDate=2025-02-17T16:22:31Z VendorInfo=gohugoio


                   | EN  
-------------------+-----
  Pages            |  8  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     |  7  
  Processed images |  0  
  Aliases          |  0  
  Cleaned          |  0  

Total in 191 ms
```

I using the branch named "patched".
You would need to build the exampleSite, not the root, using the theme.

https://github.com/simonhollingshead/hugo-coder/blob/patched/.github/workflows/regen-resources.yml#L34

This is the theme's example site, which I just use to get a regen of the SCSS into CSS.
@simonhollingshead Your content has the same characteristics as @mabster. You have four heading elements without content. Search your content for `## <!--more-->`. 

This is a bug, and we'll fix it, but for now remove the empty headings.
Failing test:

```go
func TestIssue13416(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
-- layouts/index.html --
{{ .Content }}
-- layouts/_default/_markup/render-heading.html --
-- content/_index.md --
---
title: home
---
#
`

	b := hugolib.Test(t, files)

	b.AssertFileExists("public/index.html", true)
}
```

The heading render hook must be present to trigger the error. What you put inside of the render hook template is irreleveant. If you remove the empty Markown heading (`#`) the site builds without error.

Fix patch:
diff --git a/markup/goldmark/render_hooks.go b/markup/goldmark/render_hooks.go
index 12cf0045528..1e91f7ab131 100644
--- a/markup/goldmark/render_hooks.go
+++ b/markup/goldmark/render_hooks.go
@@ -499,10 +499,10 @@ func (r *hookedRenderer) renderHeading(w util.BufWriter, source []byte, node ast
 
 	text := ctx.PopRenderedString()
 
-	// All ast.Heading nodes are guaranteed to have an attribute called "id"
-	// that is an array of bytes that encode a valid string.
-	anchori, _ := n.AttributeString("id")
-	anchor := anchori.([]byte)
+	var anchor []byte
+	if anchori, ok := n.AttributeString("id"); ok {
+		anchor, _ = anchori.([]byte)
+	}
 
 	page, pageInner := render.GetPageAndPageInner(ctx)
 


Test patch:
diff --git a/markup/goldmark/toc_integration_test.go b/markup/goldmark/toc_integration_test.go
index 7ce2e86643f..814ae199b34 100644
--- a/markup/goldmark/toc_integration_test.go
+++ b/markup/goldmark/toc_integration_test.go
@@ -258,7 +258,29 @@ title: p7 (emoji)
 `)
 
 	// emoji
+
 	b.AssertFileContent("public/p7/index.html", `
 <li><a href="#a-snake-emoji">A &#x1f40d; emoji</a></li>
 `)
 }
+
+func TestIssue13416(t *testing.T) {
+	t.Parallel()
+
+	files := `
+-- hugo.toml --
+disableKinds = ['page','rss','section','sitemap','taxonomy','term']
+-- layouts/index.html --
+Content:{{ .Content }}|
+-- layouts/_default/_markup/render-heading.html --
+-- content/_index.md --
+---
+title: home
+---
+#
+`
+
+	b := hugolib.Test(t, files)
+
+	b.AssertFileExists("public/index.html", true)
+}