Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
hi all, i have a 'url' metafield type in which i'd need to make 'dynamic'
This metafield type requires a https:// scheme and the original value is like
https://domain.com/pages/xyz
I have 2 countries and languages and i'd prefer to not translate in the translate and adapt every single url but making this 'dynamic' like
https://domain.com/dynamicCountry/dynamicLanguage/pages/xyz
or even just
https://dynamicdomain%country&language/pages/xyz
the theme is already configured to recognize country and language so my problem here is just that the URL type metafield requires a https:// start and that isn't allowing me to add only the /pages/xyz that would inheritate the domain/country/language as done in other page.
any thoughts? thanks in advance
Hi,
Try below-
{% assign country = shop.locale %}
{% assign language = shop.language %}
<!-- dynamic URL -->
{% assign dynamic_url = "https://domain.com/" | append: shop.locale | append: "/" | append: shop.language | append: "/pages/xyz" %}
<a href="{{ dynamic_url }}">Dynamic url page</a>
Thanks,
T
thanks! this seems a code for the theme, but i'd need to add this in a 'url' metafield placeholder - wdyt?
i think you can use Metafields API for that. You'll need a small app or a serverless function to do this. The process would be:
hope that helps!
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025