Custom Code - Render metafield as product title

Topic summary

A user created a product metafield called custom.alt_product_title to store alternative product titles. They needed custom Liquid code for Product Page and Collection Page templates to conditionally display this alternative title when populated, otherwise fall back to the standard product title.

The specific code section in question rendered the product title using {{ product.title | escape }}.

Resolution: The issue was resolved successfully. While the exact solution code wasn’t shared in the thread, the user confirmed it worked perfectly, suggesting they received working Liquid conditional logic (likely checking if the metafield exists/has a value before rendering it instead of the default title).

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

Hi guys

I’ve created a product metafield custom.alt_product_title which will house an Alternative Product Title.

I’d like to use some custom code on my Product Page and Collection Page templates so that if this metafield is not empty, it populates that, or it populates the standard product title field.

For example here’s a section of the theme code where it renders the Product Title:

{{- product.title | escape -}}

How would I write the code so that if the metafield custom.alt_product_title is not empty, it populates that instead?

Thanks!
Jacqui

Worked perfectly, thank you so much!