assign

Create or update custom variables to store literal values, filtered expressions, or computed results.

Syntax

{% assign variable = value %}

Example

{% assign base = 100 %}{% assign total = base | plus: 25 %}${{ total }}

Output

$125

The assign tag creates a new template variable or updates an existing one with a literal value, expression, or filter pipeline result. Assigned variables remain available throughout the rest of the current template scope.

In programmatic keyword generation, assign simplifies long column names and prepares fallback strings before constructing HTML headings. For example: {% assign display_city = row.neighborhood | default: row.city %}. You can then reference {{ display_city }} across hero headers and meta tags without repeating verbose logic.

Try this syntax in the editor.