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

Table hook renderer not found when html output format has a zero weight and another output format has a non-zero weight #13351

Open
gwagner opened this issue Feb 6, 2025 · 11 comments
Labels

Comments

@gwagner
Copy link

gwagner commented Feb 6, 2025

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

$ hugo version
hugo v0.143.1+extended+withdeploy linux/amd64 BuildDate=unknown

Does this issue reproduce with the latest release?

Yes


When I try to build my hugo project, if there is a valid table in a markdown file, the default rss.xml template pukes at this line.

The error i receive is:

Error: error building site: render: failed to render pages: render of "<PATH>/content/author/_index.md" failed: template: _internal/_default/rss.xml:55:22: executing "_internal/_default/rss.xml" at <.Summary>: error calling Summary: table hook renderer not found

When I add the template locally to /themes//layouts/_default/rss.xml and comment out line 55 (linked above), the build works perfectly fine.

I am happy to provide any relevant config information, but I do not have anything special in the config. I am using the default Goldmark Markdown Renderer.

markup:
  goldmark:
    extensions:
      typographer: false
    renderer:
      unsafe: true
@gwagner
Copy link
Author

gwagner commented Feb 6, 2025

A bit more context, when I comment out the tables in my markdown, the default template works.

When modifying the template locally, it doesn't matter if I try to use .Content instead of .Summary or if I try to truncate either of them before the table. Each permutation still leads to the same error.

When following this: https://gohugo.io/render-hooks/tables/
I added file <PATH>/themes/<THEME>/layouts/_default/_markup/render-table.html using the example provided in the URL above. There is no change, and the error is still the same.

The only temp fix is to comment or remove line 55.

@jmooring
Copy link
Member

jmooring commented Feb 6, 2025

if there is a table in a valid table in a markdown file

I'm not sure what that means. It would be helpful if you could provide a reproducible example (e.g., a repository).

@gwagner
Copy link
Author

gwagner commented Feb 6, 2025

@jmooring it is in a private repo, I will work up an example file with the failing condition in it and I will post it here.

I also corrected the typo in the original bug report above.

@jmooring
Copy link
Member

jmooring commented Feb 6, 2025

I am unable to reproduce the problem as described:

git clone --single-branch -b hugo-github-issue-13351 https://github.com/jmooring/hugo-testing hugo-github-issue-13351
cd hugo-github-issue-13351
hugo server

So there's obviously something different about your site.

@jmooring
Copy link
Member

jmooring commented Feb 9, 2025

@gwagner Are you able to provide a reproducible example?

@wolfspyre
Copy link

I'm experiencing the same thing, but mine is occurring in my json index templates trying to parse .Summary

still trying to pare down to a minimum reproducible set to see if I can isolate what's up.

There's certainly AN issue.... but it's cause isn't immediately obvious

Like the OP, I first attempted to add the unfindable template.

I tried adding it as <projroot>/layouts/_default/_markup/render-table.html

After reverting my uses of try in resources.getremote calls as try doesn't exist in earlier versions,

  • 0.140.0
  • 0.140.1
  • 0.140.2
    all work as expected. The issue begins to manifest in my case at 0.141.x

140.x:

DEBUG Write redirect to main language en: https://example.com/
INFO  build:  step render substep pages site en outputFormat manifest duration 199.887964ms
INFO  build:  step render substep pages site en outputFormat html duration 7.253810566s
INFO  build:  step render substep pages site en outputFormat json duration 476.465042ms
INFO  build:  step render substep pages site en outputFormat rss duration 27.599815ms
WARN  found no layout file for "sitemap" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "sitemap" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "sitemap" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "sitemap" for layout "simple" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
INFO  build:  step render substep pages site en outputFormat sitemap duration 3.903785ms
INFO  build:  step render substep pages site brk outputFormat manifest duration 72.549489ms
INFO  build:  step render substep pages site brk outputFormat html duration 7.973025596s
INFO  build:  step render substep pages site brk outputFormat json duration 476.125711ms
INFO  build:  step render substep pages site brk outputFormat rss duration 18.75689ms
INFO  build:  step render substep pages site brk outputFormat sitemap duration 2.58434ms
INFO  build:  step render pages 1077 content 716 duration 16.509561681s
INFO  build:  step render deferred count 0 duration 225.531µs
INFO  build:  step postProcess duration 11.677µs

141.x

INFO  static: syncing static files to / duration 59.398241ms
INFO  build:  step process substep collect files 207 files_total 207 pages_total 186 resources_total 21 duration 184.021617ms
INFO  build:  step process duration 184.07445ms
INFO  build:  step assemble duration 27.593369ms
DEBUG Write redirect to main language en: https://blahg.wolfspyre.com/
INFO  build:  step render substep pages site en outputFormat manifest duration 162.368551ms
INFO  build:  step render substep pages site en outputFormat html duration 6.800785209s
INFO  build:  step render pages 356 content 194 duration 6.98231873s
INFO  build:  step render deferred count 0 duration 2.912µs
INFO  build:  step postProcess duration 11.755µs

I see no mention in the 141 run of the alternate language my site uses but I think it's dying before it gets to that.

I suspect that some breaking config restructuring or something occurred between 140 and 141 ...

sigh
will followup as I discover more

@jmooring
Copy link
Member

As mentioned above, I am unable to reproduce this problem with the test repo above. It would helpful if someone were able to share a repository.

@wolfspyre
Copy link

wolfspyre commented Feb 20, 2025

https://gitlab.wolfspyre.io/wolfspyrelabs/open/blogsite does manifest the problem.
I have not yet narrowed the problem down to a distinct root cause tho, and I didn't want to misconvey an expectation that you attempt to do so for me.....

I'm sure there's a plethora of things I'm doing horrifically wrong here that could be related/adjacent .. :)

@jmooring
Copy link
Member

jmooring commented Feb 20, 2025

The error is triggered when (a) the html output format has a zero weight, and (b) another output format has a non-zero weight.

I have not verified this, but I suspect this is unintentional side effect of #13263.

Failing test case:

func TestIssue13351(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
[outputs]
home = ['html','json']
[outputFormats.html]
weight = 1
[outputFormats.json]
weight = 2
-- content/_index.md --
---
title: home
---
a|b
:--|:--
1|2
-- layouts/index.html --
{{ .Content }}
-- layouts/index.json --
{{ .Content }}
`

	b := hugolib.Test(t, files)
	b.AssertFileContent("public/index.html", "<table>") // pass
	b.AssertFileContent("public/index.json", "<table>") // pass

	files = strings.ReplaceAll(files, "weight = 1", "weight = 0")

	b = hugolib.Test(t, files)
	b.AssertFileContent("public/index.html", "<table>") // fail: error calling Content: table hook renderer not found
	b.AssertFileContent("public/index.json", "<table>")
}

There may be variations on this, but the above was the simplest example I could contrive.

@jmooring jmooring changed the title RSS Template Errors When Table Present in Markdown Table hook renderer not found when html output format has a zero weight and another output format has a non-zero weight Feb 20, 2025
@wolfspyre
Copy link

Your knowledge of the innards of Hugo never cease to amaze me.

I appreciate your skill, and am sincerely appreciative for the energy you consistently contribute to the project..
Thank you.

@wolfspyre
Copy link

I can confirm that ensuring that all outputformats specified in the site config have a weight associated with them that is greater than 1 seems to resolve the issue I was experiencing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants