How to create the custom filter in collection page for the product variant option for size only

Hi want create the new filter for better the user expirnce.

i can get the filter by product tag that was not right way.

may be this was can be work.

`

{% for tag in collection.all_tags %}
{% if tag contains ‘Size’ %}

  • {{ tag | remove: 'Size-' }}
  • {% endif %} {% endfor %}

    `