How can I add a downloadable PDF file to each product using Shopify metafields and Liquid?

Hi friends!
One query, I am using shopify metafields to add a PDF file on each product. The idea is that this file can be downloaded, as the metafield does not appear in the dynamic tags of the os2.0 theme I decided to implement it by Liquid following this reference https://shopify.dev/api/liquid/objects/metafield?shpxid= 5fcdc0d7-1460-458C-1648-0A8A15A7F62C
With this code:

 Hoja  Descargar  

But I can’t get the link to download the corresponding file, failing that it shows me a link / products / GenericFileDrop

Could you help me?

You need to add .url at the end

1 Like

{{ product.metafields.my_fields.hoja_de_seguridad.value.url }}

Something changed now should be {{ product.metafields.my_fields.hoja_de_seguridad | file_url }}

2 Likes