The Capture Tag
  • 04 Apr 2025
  • 1 minute read
  • Dark
    Light
  • PDF

The Capture Tag

  • Dark
    Light
  • PDF

Article summary

In Liquid markup, the capture tag saves content as a new variable that you can use.

While superficially similar to the assign tag, capture allows you to, aptly, capture multi-line content, HTML and other liquid markup. Think of the capture tag as storing a detailed list that you can reference elsewhere.

Here’s an explanation by way of a non-Slate example:

Imagine that you have 12 Slate Sharks and you want to keep a detailed list of what you’re going to do with those Sharks:

  • Count the Sharks

  • Decide how many you might want to keep, or give away

  • Write a message like “I have 12 Slate Sharks, but I know I want to give some away, but I must keep 2 for myself.”

You could capture all of these thoughts in one capture tag format them as an HTML list:

{% capture slate-shark-information %}
<ul>
    <li>Count the Sharks</li> 
    <li>Decide how many you might want to keep, or give away</li>
    <li>Write a message like “I have 12 Slate Sharks, but I know I want to give some away, but I must keep 2 for myself.”</li>
</ul>
{% endcapture %}

The HTML <ul> (unordered list) and <li> (list item) tags are preserved and print the items as a bulleted list.

You can now print this content any time you call the merge field we designated with the opening tag, {{slate-shark-information}}.

How to use capture

The capture tag defines a variable that stores content.

Any content between {% capture %} and {% endcapture %} is stored as a string and assigned to that particular variable name:

{% capture signature %}
    {{User-First}} {{User-Last}}
    {{User-Title}}
    Slate University
{% endcapture %}

In this example, we have a capture tag with a variable name signature.

The tag stores three lines of text, containing values for the fields User First, User Last, Title and the text Slate University.

The captured content appears wherever in the document we use {{signature}}.

📖 Further reading: See the Shopify documentation on the capture tag.


Was this article helpful?