gohugoio/hugo · error
no code renderer found for %q
Error message
no code renderer found for %q
What it means
Hugo's Goldmark code-block renderer resolves a render hook for every fenced code block via `GetRenderer(hooks.CodeBlockRendererType, lang)`. If no renderer is registered for the block's language — neither a user `render-codeblock` layout hook nor Hugo's built-in Chroma highlighter fallback — the AST walk stops and the page build fails naming the language string.
Source
Thrown at markup/goldmark/codeblocks/render.go:71
}
func (r *htmlRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
reg.Register(ast.KindFencedCodeBlock, r.renderCodeBlock)
}
func (r *htmlRenderer) renderCodeBlock(w util.BufWriter, src []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
ctx := w.(*render.Context)
if entering {
return ast.WalkContinue, nil
}
n := node.(*ast.FencedCodeBlock)
lang := getLang(n, src)
renderer := ctx.RenderContext().GetRenderer(hooks.CodeBlockRendererType, lang)
if renderer == nil {
return ast.WalkStop, fmt.Errorf("no code renderer found for %q", lang)
}
ordinal := ctx.GetAndIncrementOrdinal(ast.KindFencedCodeBlock)
var buff bytes.Buffer
l := n.Lines().Len()
for i := range l {
line := n.Lines().At(i)
buff.Write(line.Value(src))
}
s := htext.Chomp(buff.String())
var info []byte
if n.Info != nil {
info = n.Info.Segment.Value(src)
}View on GitHub ↗ (pinned to 8a468df065)
Solutions
- Ensure the built-in fallback is available: leave markup.highlight.codeFences enabled (default true) so unhandled languages fall back to the Chroma renderer.
- Add or restore a codeblock render hook for the language: layouts/_markup/render-codeblock-<lang>.html or a generic render-codeblock.html.
- Fix the fence's info string if it contains a garbled/unintended language token.
- If a theme provided the hook, confirm the theme module/version still ships it after upgrades.
Example fix
<!-- before: layouts has no hook and highlighting disabled -->
```mermaid
graph TD; A-->B;
```
<!-- after: add layouts/_markup/render-codeblock-mermaid.html -->
<pre class="mermaid">{{ .Inner | htmlEscape | safeHTML }}</pre> Defensive patterns
Strategy: fallback
Validate before calling
// ensure a matching render hook exists for each fenced language you use, e.g. // layouts/_markup/render-codeblock-mermaid.html for ```mermaid blocks
Prevention
- Provide a specific render hook (layouts/_markup/render-codeblock-<lang>.html) for every custom code block language your content uses
- Add a generic layouts/_markup/render-codeblock.html as the catch-all fallback renderer
- Audit content for fenced languages (grep '```' | sort -u) when adding or removing render hooks
- Remember theme-provided hooks can be shadowed or removed by project-level layouts
When it happens
Trigger: Rendering a markdown fenced code block whose info string maps to a language for which no code-block renderer resolves. In practice this surfaces when the built-in highlighter path is unavailable (e.g. `markup.highlight.codeFences=false` combined with hook lookup changes) or a custom `layouts/_markup/render-codeblock-<lang>.html` setup leaves a language unhandled in an edge configuration.
Common situations: Themes providing per-language codeblock render hooks (e.g. render-codeblock-mermaid.html) removed or renamed during a theme upgrade; disabling code fences / highlighting in config while content still relies on codeblock rendering; Hugo version changes in render-hook resolution order exposing unusual info strings (odd characters in the fence language).
Related errors
- project config markup.goldmark.renderHooks.image.useEmbedded
- project config markup.goldmark.renderHooks.link.useEmbedded
- unrecognized render hook template
- goldmark: %s
- failed to parse Markdown attributes; you may need to quote t
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/b00e52a05d5fe084.json.
Report an issue: GitHub ↗.