Automatic Syntax Highlighting for Hugo templates

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 :wink: )

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

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

4 Likes