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>