I am trying to add breadcrumbs for my product pages on an ecommerce store. I need some help with the liquid syntax.
I want to include the first product tag as a part of the breadcrumb, unless the tag is 'stickers', 'stationery', or 'accessories', in which case I would like to use the second tag. If the second tag is also either 'stickers', 'stationery', or 'accessories', I would like to use the third tag, and so on.
Perhaps a better way to say this would be: I would like to call the first available tag that isn't either 'stickers', 'stationery', or 'accessories'.
The closest I have gotten is this:
{% if product.tags.first contains 'stickers' or product.tags.first contains 'stationery' or product.tags.first contains 'accessories' %}
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/collections/all/{{ product.tags.last }}" itemprop="url"><span itemprop="title">{% if product.tags.size > 0 %}{% assign words = product.tags.last | split: '-' %}{% for word in words %}{% if word == 'and' %}{{ word }} {% else %}{{ word | capitalize }} {% endif %} {% endfor %}{% endif %}</span></a></li>
{% else %}
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/collections/all/{{ product.tags.first }}" itemprop="url"><span itemprop="title">{% if product.tags.size > 0 %}{% assign words = product.tags.first | split: '-' %}{% for word in words %}{% if word == 'and' %}{{ word }} {% else %}{{ word | capitalize }} {% endif %} {% endfor %}{% endif %}</span></a></li>
{% endif %}
This is inelegant, but it works up until a point. The point at which is breaks down is when both the first and last tags fall into one of the categories I wanted to exclude.
As far as I can see, there doesn't seem to be an option to call something like "product.tags.second" (only "first" and "last" seem to work).
I am a little out of my depth and would really appreciate some advice on how to sort this out.
The platform I'm on is Shopify.
Thanks!