Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hugo-coder theme no longer builds on 0.144.0 - "interface conversion: interface {} is nil, not []uint8" #13416

Closed
simonhollingshead opened this issue Feb 18, 2025 · 10 comments · Fixed by #13417
Assignees
Milestone

Comments

@simonhollingshead
Copy link

simonhollingshead commented Feb 18, 2025

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.

@mabster
Copy link

mabster commented Feb 18, 2025

I have the same build error over at https://github.com/mabster/mabster.github.io

@simonhollingshead simonhollingshead changed the title Site no longer builds on 0.144.0 - "interface conversion: interface {} is nil, not []uint8" hugo-coder theme no longer builds on 0.144.0 - "interface conversion: interface {} is nil, not []uint8" Feb 18, 2025
@mabster
Copy link

mabster commented Feb 18, 2025

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.

@jmooring
Copy link
Member

jmooring commented Feb 18, 2025

Yes, this is a bug.

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

# <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.

@mabster
Copy link

mabster commented Feb 18, 2025

@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.

@jmooring
Copy link
Member

@mabster None of the HTML elements have inner content. The icon rendering is a CSS thing.

@jmooring
Copy link
Member

jmooring commented Feb 18, 2025

@simonhollingshead How do I reproduce the problem with your site? I did this:

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

And got this:

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".

@simonhollingshead
Copy link
Author

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.

@jmooring
Copy link
Member

@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.

@jmooring
Copy link
Member

jmooring commented Feb 18, 2025

Failing test:

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.

bep added a commit to bep/hugo that referenced this issue Feb 18, 2025
@bep bep removed the NeedsTriage label Feb 18, 2025
@bep bep self-assigned this Feb 18, 2025
@bep bep added this to the v0.144.1 milestone Feb 18, 2025
bep added a commit to bep/hugo that referenced this issue Feb 18, 2025
bep added a commit that referenced this issue Feb 18, 2025
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants