# Automatic Syntax Highlighting for Hugo templates

**URL:** <https://discourse.gohugo.io/t/automatic-syntax-highlighting-for-hugo-templates/57541>\
**Category:** tips & tricks\
**Tags:** forum\
**Created:** [September 10, 2026, 5:43pm UTC](https://discourse.gohugo.io/t/automatic-syntax-highlighting-for-hugo-templates/57541 "2026-09-10T17:43:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [September 10, 2026, 5:43pm UTC](https://discourse.gohugo.io/t/automatic-syntax-highlighting-for-hugo-templates/57541/1 "2026-09-10T17:43:39Z")

</div>

A while ago automatic syntax highlighting has been added to our forum.

That means, it is not necessary anymore to set a fenced code block in the forum to a less breaking language aka _ruby__php_ or assigning _text_. (unless you want to keep it dry 😉 )

The autodetection seems to work fine, so if you have a Hugo template (not a shortcode) just use

- ````` for autotetection
- ` ```hugo-html` to choose it manually

for more details check out [Proposal: Add highlighting support for Go/Hugo templates to Discourse](https://discourse.gohugo.io/t/proposal-add-highlighting-support-for-go-hugo-templates-to-discourse/57307)

```auto
{{ with resources.Get "css/main.css" | css.Build }}
  {{ if hugo.IsDevelopment }}
    <link rel="stylesheet" href="{{ .RelPermalink }}">
  {{ else }}
    {{ with . | fingerprint }}
      <link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
    {{ end }}
  {{ end }}
{{ end }}

```

p.s. it’s dedicated to hugo so _go-html-template_ or _go-template_ won’t work.
