In Shopify I am trying to build a string of the current tags in my shopify store.
If I am on the page:
mysite.com/collections/all/tag1+tagC+tag4
I need to be able to get the current tags as one full string without spaces:
tag1+tagC+tag4
My code is currently like so:
{% if current_tags %}
{% assign current_filters = '' %}
{% for tag in current_tags %}
{% if forloop.last == false %}
{{ current_filters | append: tag | handleize | append: '+'}}
{% else %}
{{ current_filters | append: tag | handleize}}
{% endif%}
{% endfor %}
{% endif %}
If I then output
{{current_filters}}
I get
tag1+ tagC+ tag4
Firstly how do I go about getting this string without the space after the plus sign? I have tried using | strip without luck and also putting my code within {%- -%}
Secondly when I then try and append that current_filters variable onto the end of another variable it is blank/empty
{% assign current_collection = collection.handle %}
{% assign base_url = shop.url | append: '/collections/' | append: current_collection | append: '/' | append: current_filters %}
Outputting base_url just returns
mysite.com/collections/all/
not
mysite.com/collections/all/tag1+tagC+tag4
Why is this working when I just use {{current_filters}} but not .. append: current_filters