Reference a variable from another liquid file

Topic summary

A developer working with Shopify’s Prestige theme needs to access a Liquid variable across different template files. They created a variable in product-meta.liquid that splits product descriptions into sections, but need to reference it in product-template.liquid.

The Issue:

  • Variables assigned in one Liquid file aren’t automatically available in other files
  • Each template renders independently without shared variable scope
  • Liquid doesn’t support true global variables across templates

The Solution:
Re-assign the same variable in product-template.liquid using identical logic:

{% assign description__split = product.description | replace: 'data-section-type', 'data-section-type-placeholder' | split: '--split--' %}
{{ description__split[1] }}

This approach duplicates the variable assignment in each file where it’s needed, allowing access to different array indices ([0] in product-meta, [1] in product-template) of the split description.

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

Hello,

I got a variable which splits my description into different areas.

Problem is my variable needs to be in another .liquid file. It was how prestige theme was set up.

The description above Add to Cart is in the Product-Meta.liquid file. and the second description I need it to be in the Product-Template.liquid file.

What’s in my Product-Meta.Liquid File

{% assign description__split = product.description | replace: ‘data-section-type’, ‘data-section-type-placeholder’ | split: “–split–” %}
{{ description__split[0] }}

How do I reference the above varible in my Product-Template.liquid? Below is what I currently got.

{{ description__split[1] }}

In Shopify Liquid, variables assigned in one file (like product-meta.liquid) are not automatically available in another file (like product-template.liquid), because each file is rendered independently. Liquid doesn’t have true global variables across templates.

:white_check_mark: Solution

You need to assign the variable again in product-template.liquid using the same logic.

:hammer_and_wrench: Updated Code for product-template.liquid:

{% assign description__split = product.description | replace: 'data-section-type', 'data-section-type-placeholder' | split: '--split--' %}
{{ description__split[1] }}