capture

Capture rendered template content between tags and assign the combined string result to a variable.

Syntax

{% capture variable %} ... {% endcapture %}

Example

{% assign name = "Austin" %}{% capture greeting %}Welcome to {{ name }}!{% endcapture %}{{ greeting }}

Output

Welcome to Austin!

The capture tag records all template output rendered between its opening and closing tags, storing the resulting text as a single string variable. Unlike assign, capture can enclose multiple lines and conditional evaluations.

On keyword combination landing pages, capture assembles rich meta titles and Open Graph snippets combining several row attributes. For example: {% capture meta_desc %}Certified {{ row.specialty }} contractors in {{ row.city }}. {{ row.guarantee | default: 'Free estimates available.' }}{% endcapture %}. This builds cohesive search descriptions.

Try this syntax in the editor.