Using Metafields as Link to Documentation

I’m attempting to add a “Documentation” link to products via metafields.

First, I create a metafield ‘products.metafields.my_fields.product_documentation’ to a URL type, and placed the URL inside that field.

Then on the Product Template I’m adding the Custom Liquid option. The idea here is that if the documentation link has anything in it (which would be a URL) then it would show a link to documentation. I’ve tried a few things and can’t seem to get it to work.

All of these were tested with a value in the relevant metafield.

{%- if products.metafields.my_fields.product_documentation -%}Documentation

{%- endif -%}

Nothing happens

{% if products.metafields.my_fields.product_documentation == TRUE%}Documentation

{% endif %}

The link will appear, the URL is not formatted correctly.

{% if products.metafields.my_fields.product_documentation == 1%}Documentation

{% endif %}

As expected the documentation link did NOT show up.

Do I need to do something to get products.metafields.my_fields.product_documentation to return the actual URL that’s been placed inside the metafeild?

Hi @SyncConsult ,

First you need to go to the products and add the URL for it.

Then you change the code:

{%- if products.metafields.my_fields.product_documentation != blank -%}Documentation

{%- endif -%}

Hope it helps!

Thank you. Not having luck with this working. Will keep trying.

Disregard. not working

Hi @SyncConsult ,

Have you successfully created Metafields for your collection?

Yes. Metafield was there.

I’ve given up on this for now. Thank you for your help.

1 Like

I just had this exact problem.

You need to use product.metafields not products.metafields - remove the s.