Does Hugo support dynamic HTML element tags using variables

The whole html instead gets printed in the frontend <h1 class="inline-block"> FOO</h1>

  {{- /* 1. Determine element tag based on whether we are on the homepage */ -}}
  {{- $headingTag := cond .IsHome "h1" "div" }}

  {{- /* 2. Render wrapper element */ -}}
<{{ $headingTag }} class="inline-block">
    <a href="{{ site.Home.RelPermalink }}">{{ site.Title }}</a>
 </{{ $headingTag }}>

See https://gohugo.io/functions/safe/.

I had tried different iterations of safeHTML before posting, but Claude just fixed it for me

{{- /* 1. Determine element tag based on whether we are on the homepage */ -}}
{{- $headingTag := cond .IsHome "h1" "div" }}
{{- $headingClass := "inline-block" }}

{{- /* 2. Render wrapper element */ -}}
{{ printf `<%s class="%s">` $headingTag $headingClass | safeHTML }}
  <a href="{{ site.Home.RelPermalink }}">{{ site.Title }}</a>
{{ printf `</%s>` $headingTag | safeHTML }}