# Bug or Feature? language-less code blocks use "default" formatting

**URL:** <https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001>\
**Category:** support\
**Created:** [April 15, 2026, 6:29pm UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001 "2026-04-15T18:29:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [April 15, 2026, 6:29pm UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001/1 "2026-04-15T18:29:17Z")

</div>

I add this to a markdown file:

````auto
```
@all-contributors add @YOURUSERNAME for YOURCONTRIBUTIONTYPE
```

````

 ![Screenshot2026-04-1601-24-43](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/6/9/69bc07586460fe2fac6b869b1511e9ca2c5056a4.png)

and Hugo is rendering it in the hugo-default dark theme (even with me having defined styles in css for highlighting)

I add this:

````auto
```plaintext
@all-contributors add @YOURUSERNAME for YOURCONTRIBUTIONTYPE
```

````

 ![Screenshot2026-04-1601-25-58](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/2/2/22a585d0fce66a168cd1995ddcfda9d0b53a858d.png)

and it’s showing up in the color scheme I set.

Also… it reacts to my custom css additions that do some magic with the data properties.

This is either a bug or something expected. If my code block DOES NOT have a language type added it will default to the standard theme and does NOT add any of the options I set (like `noClasses`in this case).

My config in `config/*/markup.toml` is this:

```auto
[highlight]
anchorLineNos = true
codeFences = true
noClasses = false
[goldmark.renderer]
unsafe = true # meh, no like, but required for contributors list

```

and I added the styles for “my” theme to the stylesheet. “MY” theme is not a dark them (gruvbox-light I think). The theme is exported into a stylesheet via `hugo gen chromastyles --style=gruvbox-light > assets/ananke/css/highlighting.css`.

Is this A) a bug or B) some issue in my configuration? (repo is [here](https://github.com/theNewDynamic/gohugo-theme-ananke))

We are on the latest Hugo version.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 15, 2026, 7:10pm UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001/2 "2026-04-15T19:10:16Z")

</div>

Yeah, this is known (at least to me) behavior, but we should document it here:  
[https://gohugo.io/content-management/syntax-highlighting/#lang](https://gohugo.io/content-management/syntax-highlighting/#lang)

And perhaps some other places too (short code, highlight function). I’ll create a [docs issue](https://github.com/gohugoio/hugoDocs/issues/3476).

There’s a related proposal here:

- [https://github.com/gohugoio/hugo/issues/8913](https://github.com/gohugoio/hugo/issues/8913)

I looked into this a while ago, and decided to bail but I don’t remember why.

For now, to meet your needs, I would create a codeblock render hook and set the lang to `text` if not specified.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 15, 2026, 7:11pm UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001/3 "2026-04-15T19:11:37Z")

</div>

And this may be useful:

[https://discourse.gohugo.io/t/add-option-to-use-default-chroma-lexer-for-code-fences-with-no-language/55368/3](https://discourse.gohugo.io/t/add-option-to-use-default-chroma-lexer-for-code-fences-with-no-language/55368/3)

The render hook (`layouts/_markup/render-codeblock.html`) is trivial:

```plaintext
{{- $lang := "text" }}
{{- $options := .Options }}
{{- if transform.CanHighlight .Type }}
  {{- $lang = .Type }}
{{- else }}
  {{- $options = .Attributes }}
{{- end }}

{{- transform.Highlight .Inner $lang $options }}

```

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [April 15, 2026, 7:19pm UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001/4 "2026-04-15T19:19:56Z")

</div>

Yeah, pushing it through a render hook might be a good idea.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [April 15, 2026, 7:20pm UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001/5 "2026-04-15T19:20:06Z")

</div>

> [@jmooring](#):
>
> I looked into this a while ago, and decided to bail but I don’t remember why.

I remember now. I decided to bail because, without a language specified in the info string, a fenced code block renders identically to an indented code block. Since you can’t specify a language with an indented block anyway, this is arguably the expected behavior.

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [May 26, 2026, 4:56am UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001/6 "2026-05-26T04:56:54Z")

</div>

Note that the approach I described above will not work with v0.162.0 and later.

#### Why?

Because we fixed the [bug](https://github.com/gohugoio/hugo/issues/14909) where syntax highlighting options were not in the [`Options`](https://gohugo.io/render-hooks/code-blocks/#options) map passed to the code block render hook when the code language (`Type`) was absent or unsupported. Instead, they were in the [`Attributes`](https://gohugo.io/render-hooks/code-blocks/#attributes) map. That is no longer the case.

#### What can I do instead?

You now have the ability to override the code language (`Type`) when calling the [`transform.HighlightCodeBlock`](https://gohugo.io/functions/transform/highlightcodeblock/) function in a code block render hook. For example, to fall back to plain text when the language is not specified or not supported by the highlighter:

```plaintext
{{- $opts := dict }}
{{- if not (transform.CanHighlight .Type) }}
  {{- $opts = dict "type" "text" }}
{{- end }}
{{- $result := transform.HighlightCodeBlock . $opts }}
{{- $result.Wrapped }}

```

Let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [May 28, 2026, 4:57am UTC](https://discourse.gohugo.io/t/bug-or-feature-language-less-code-blocks-use-default-formatting/57001/7 "2026-05-28T04:57:15Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
