Liquid Course for ConvertKit

Liquid Cheatsheet

Quick reference guide for Liquid in ConvertKit

A quick reference guide for using Liquid in ConvertKit.

Basic Syntax

Output

{{ variable }}           {# Output a variable #}
{{ "Hello" }}           {# Output a string #}
{{ 42 }}                {# Output a number #}

Logic

{% if condition %}       {# If statement #}
{% elsif condition %}    {# Else if #}
{% else %}              {# Else #}
{% endif %}             {# End if #}

ConvertKit Variables

Subscriber Data

{{ subscriber.first_name }}
{{ subscriber.email }}
{{ subscriber.id }}
{{ subscriber.state }}
{{ subscriber.created_at }}
{{ subscriber.updated_at }}

Tags and Custom Fields

{{ subscriber.tags }}                    {# Array of tags #}
{{ subscriber.custom_fields.field_name }} {# Custom field value #}

Form and Sequence

{{ form.name }}
{{ form.id }}
{{ sequence.name }}
{{ sequence.id }}
{{ sequence.step_number }}
{{ sequence.total_steps }}

Operators

Comparison

==    {# equals #}
!=    {# not equals #}
>     {# greater than #}
<     {# less than #}
>=    {# greater than or equal to #}
<=    {# less than or equal to #}
contains {# check if value exists in array #}

Logical

and   {# logical AND #}
or    {# logical OR #}

Loops

Basic Loop

{% for item in items %}
  {{ item }}
{% endfor %}

Loop with Index

{% for item in items %}
  {{ forloop.index }}. {{ item }}
{% endfor %}

Loop Variables

forloop.index      {# 1-based index #}
forloop.index0     {# 0-based index #}
forloop.first      {# true if first iteration #}
forloop.last       {# true if last iteration #}
forloop.length     {# total number of items #}

Filters

String Filters

{{ string | capitalize }}    {# Capitalize first letter #}
{{ string | downcase }}      {# Convert to lowercase #}
{{ string | upcase }}        {# Convert to uppercase #}
{{ string | strip }}         {# Remove whitespace #}
{{ string | replace: "old", "new" }}  {# Replace text #}
{{ string | truncate: 5 }}   {# Truncate to length #}

Number Filters

{{ number | plus: 1 }}       {# Add #}
{{ number | minus: 1 }}      {# Subtract #}
{{ number | times: 2 }}      {# Multiply #}
{{ number | divided_by: 2 }} {# Divide #}
{{ number | round: 2 }}      {# Round to decimal places #}
{{ number | ceil }}          {# Round up #}
{{ number | floor }}         {# Round down #}

Date Filters

{{ date | date: "%Y-%m-%d" }}        {# Format date #}
{{ date | date: "%B %d, %Y" }}       {# Month Day, Year #}
{{ date | date: "%I:%M %p" }}        {# Time with AM/PM #}

Array Filters

{{ array | first }}          {# First item #}
{{ array | last }}           {# Last item #}
{{ array | join: ", " }}     {# Join with separator #}
{{ array | size }}           {# Number of items #}
{{ array | sort }}           {# Sort array #}
{{ array | uniq }}           {# Remove duplicates #}

Common Patterns

Check if Variable Exists

{% if variable %}
  {{ variable }}
{% endif %}

Check if Tag Exists

{% if subscriber.tags contains "tag_name" %}
  Content for tagged subscribers
{% endif %}

Multiple Conditions

{% if condition1 and condition2 %}
  Both conditions are true
{% endif %}
 
{% if condition1 or condition2 %}
  Either condition is true
{% endif %}

Case Statement

{% case variable %}
  {% when "value1" %}
    Content for value1
  {% when "value2" %}
    Content for value2
  {% else %}
    Default content
{% endcase %}

Assign Variables

{% assign new_variable = value %}
{% assign calculation = number | times: 2 %}

Best Practices

  1. Always check if variables exist

    {% if subscriber.first_name %}
      {{ subscriber.first_name }}
    {% endif %}
  2. Use meaningful variable names

    {% assign days_remaining = subscriber.custom_fields.trial_days %}
  3. Comment your code

    {# This section handles trial users #}
    {% if subscriber.tags contains "trial" %}
      ...
    {% endif %}
  4. Keep logic simple

    {% assign is_vip = subscriber.tags contains "vip" %}
    {% if is_vip %}
      VIP content
    {% endif %}
  5. Use filters for formatting

    {{ subscriber.created_at | date: "%B %d, %Y" }}
    {{ price | round: 2 }}

Common Errors

  1. Missing end tags

    {% if condition %}  {# Don't forget the endif! #}
      Content
    {% endif %}
  2. Incorrect filter syntax

    {{ string | replace: "old", "new" }}  {# Correct #}
    {{ string | replace "old" "new" }}    {# Incorrect #}
  3. Using wrong delimiters

    {{ variable }}  {# For output #}
    {% if condition %}  {# For logic #}
  4. Not checking for null values

    {% if subscriber.custom_fields.field_name %}
      {{ subscriber.custom_fields.field_name }}
    {% endif %}

Quick Tips

  • Use {% comment %} for multi-line comments
  • Use {% raw %} to output Liquid code
  • Use {% assign %} to store complex calculations
  • Use filters to format data instead of JavaScript
  • Test your templates with different subscriber data
🚀 Early Access - 50% OFF

Give Your Visitors
the Proof They Need

ProofyBubble turns casual visitors into customers by leveraging social proof to build trust and credibility.

Buy once, yours forever
1-minute setup
Increase Conversion Rate
Get Lifetime Access

30-day money-back guarantee

Profile

"When I launched my course, ProofyBubble helped me get 100+ sales in the first month!"

Ankita Kulkarni • 13.2K YouTube Subscribers