Liquid, JavaScript, themes, sales channels
I have a metaobject called "brand" within a metafield "created_by" and I want to use the slug of the "name" key of the brand to create a link to the brand page template. Example link... https://www.beforeourtime.com/pages/brand/colors-greys
"colors & greys" is the name of a brand. This is the metaobject definition... https://snipboard.io
This is how I reference the brand name on my product page template...
{{ product.metafields.custom.created_by.value.name }}
Solved! Go to the solution
This is an accepted solution.
Hi,
1. Create a Metafield-->Assign a Value(This value could be a string that you want to use as a part of the URL slug.)
2. Generate the slug using the metafield value, you can use liquid code. Here's an example for a product:
{% assign product_metafield = product.metafields.namespace.key %}
{% assign slug = product_metafield | handle %}
In this code:
product.metafields.namespace.key should be replaced with the actual namespace and key of your metafield.
handle is a filter in liquid that converts a string into a URL-friendly slug. It removes spaces, converts to lowercase, and replaces special characters.
Use the generated Slug in Your URLs
Example
custom product URL
<a href="/products/{{ slug }}">{{ product.title }}</a>
If you still need help from our side you can contact us through given details at signature
This is an accepted solution.
Hi,
1. Create a Metafield-->Assign a Value(This value could be a string that you want to use as a part of the URL slug.)
2. Generate the slug using the metafield value, you can use liquid code. Here's an example for a product:
{% assign product_metafield = product.metafields.namespace.key %}
{% assign slug = product_metafield | handle %}
In this code:
product.metafields.namespace.key should be replaced with the actual namespace and key of your metafield.
handle is a filter in liquid that converts a string into a URL-friendly slug. It removes spaces, converts to lowercase, and replaces special characters.
Use the generated Slug in Your URLs
Example
custom product URL
<a href="/products/{{ slug }}">{{ product.title }}</a>
If you still need help from our side you can contact us through given details at signature
Thanx Bro!
User | RANK |
---|---|
38 | |
28 | |
13 | |
13 | |
9 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023