Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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!
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025