How to limit number of tags printed

Maybe I’m getting you wrong - but what about:

{{- $.Scratch.Set "myLimit" 0 }}
{{- range $name, $items := .Site.Taxonomies.tags }}
  {{- $.Scratch.Set "myLimit" (add ($.Scratch.Get "myLimit") 1) }}
  {{- if le ($.Scratch.Get "myLimit") ($.Site.Param `tagsLimit`) }}
    <div class="tag">
      <a href="{{ $.Site.BaseURL }}/tags/{{ $name | urlize | lower }}" class="tag-text">{{ $name }}</a>
    </div>
  {{- end }}
{{- end }}

with config.toml

[params]
tagsLimit = 5
3 Likes