How can I create breadcrumbs on a product page using tags?

Hello, I want to create a breadcrumb in product page with full path. All my products have the collection names in the tag section. For example Collection1, Collection2. So if there is a way to extract tags in order I can easy create the bradcrumb bar. For example product.tag1, product.tag2 ecc. Is it possible?

Hi @FrancescoMi89 ,

Your current solution will create issues when your product will have multiple tags in it, as you will not be able to judge which tag is the collection name.

Would recommend following the below URL and checking if it suits you…

Hope it will help…

Yes, maybe I have another solution.

Each product have a product type that matches the collection, so in the product page of this product I can display the metafield of that product.

{{ collection.metafields.custom.metafield1 }} doesn’t work because of course I’m not in the collection page, so I need to link collection.metafields.custom.metafield1 and product.type, but I don’t know how. Can you help me?

Hope I was clear, thank you.

@FrancescoMi89

Your logic seems right for that you just need if statement for

product.type == collection.metafiels.custom.metafield in main-product.liquid

However it will create issue when your multiple collection will have same product.

For possible best solution according to me is mentioned below, let me know your suggestion.

Considering you have knowledge of coding, below is the flow.

  1. Write script code at collection listing for product block.

  2. When the user clicks on the product on the listing page.

  3. Store the current collection name and its URL somewhere. replace that variable every time the user clicks on the product.

  4. By this way you will have the last visited collection name and URL in the variable.

  5. At the product page you just need to update the current breadcrumb value with stored info.

Hope this will helps…