How to compare the url of the current page and the url of the link

I want to create a small filter for a blog and want to display categories in the select tag. I am interested in the question of how to add the selected attribute to the option tag if the address of the current taxonomy matches the value value

<select name="category" id="categories-list" class="form-select" onchange="changeCategory()">
      <option>All Categories</option>
      {{ range $name, $taxonomy := .Site.Taxonomies.categories }}
      {{ with $.Site.GetPage (printf "/categories/%s" $name) }}
{{ if current_url == taxonomy_url }}
      <option value="{{ .RelPermalink }}" selected>{{$name}}</option>
{{ else }}
<option value="{{ .RelPermalink }}">{{$name}}</option>
{{ end }}
      {{ end }}
      {{ end }}
    </select>

Hints:

  • Your text uses different wording than your example code
  • you depend on content, config and layouts. So best would be to provide a small repo to analyse.

Ok summertime but might raise chance to get an answer