If statement with shortcode

I am trying to add the statement to append .html to the categories if uglyurl is set to true. However It does not allow me and throws me the following error.

parse failed: template: partials/sidebar.html:35: unexpected "<" in command

{{ if (isset .Params "uglyurls") }}
    {{ <a href="{{- "categories/" | relLangURL -}} {{- $name | urlize | lower -}}.html"> {{ .Page.Title }} ({{ $items.Count }})</a> }}
{{ else }}
    {{ <a href="{{- "categories/" | relLangURL -}} {{- $name | urlize | lower -}}"> {{ .Page.Title }} ({{ $items.Count }})</a> }}
{{ end }}

Can someone point me in the right direction to get this fixed? Thank you in advance.

You can’t nest statements like that… It is complaining because <a ... is not an actual command.

As for what you are trying to do, you are probably better of doing something like this example: Taxonomy Templates | Hugo

Using .Permalink, Hugo should be able to construct the correct URL regardless of the uglyurls setting.