Refer to a product within a page, rather than collection?

Highlighted
Tourist
10 0 6

Hi all,

I'm a little (well and truly) out of my depth here, so hopefully this makes sense.

I'm trying to avoid duplicate meta-description on my Shopify site.  My idea was the use the Shopify metadiscription you can manually enter on a collection for the first 130 characters, then draw another 30 characters from the title of the first item on each page.  This way each page can have the targeted meta-description I want, but also be unique and contain the name of one or two products on the page.

So far I have the first part working, but stuck on the second part.  This is what I've got:

{% elsif template contains 'collection' %}
    <meta name="description" content="{% assign meta_data = collection.metafields.global %}{{ meta_data.description_tag | strip_html | strip_newlines | truncate: 130 | escape }} {% for product in collection.products %} {{ product.title }} {% endfor %} " />      
    

I'm having it list the products titles in the collection at the moment, but this isn't ideal as they're going to end up the same on every page.  I'd like to have them different on each page by using the titles of the product on each page itself (rather than the titles from all products in each collection), but I'm completely stumped on how to go about it. 

I also need to cut the total characters being displayed from the product titles down to 30 characters.  I haven't been able to figure out how to get this to work (only truncate each individual product title, not the list of titles) which is probably a simple fix but I haven't managed to figure it out.

 

If anyone can offer any advice or assistance here, it would be greatly appreciated!

0 Likes
Tourist
10 0 6

Just bumping.  Might get more action during the week. 

Thanks.

0 Likes