Recipes & Tutorials
Learn by building real templates. These tutorials walk you through complete examples from start to finish.
Getting Started
-
Invoice Template
Build a complete invoice with header, line items, and totals
-
Iteration Patterns
Tables, lists, cards, and grids from array data
-
Conditional Content
Show/hide sections based on data
Quick Recipes
Display a List of Items
<ul>
{% for item in items %}
<li>{{ item.name }} - {{ item.price | format_number: "C" }}</li>
{% endfor %}
</ul>
Format a Date
Show Content Conditionally
Calculate a Total
{% assign subtotal = 0 %}
{% for item in order.items %}
{% assign lineTotal = item.price | times: item.quantity %}
{% assign subtotal = subtotal | plus: lineTotal %}
{% endfor %}
<p>Subtotal: {{ subtotal | format_number: "C" }}</p>
Add Page Numbers (PDF)
In your footer template:
<div style="text-align: center; font-size: 9px;">
Page {{tt_pageNumber}} of {{tt_totalPages}}
</div>
Generate a QR Code
Number Sections Automatically
<h2>{% secUp main %}. Introduction</h2>
<h2>{% secUp main %}. Methods</h2>
<h2>{% secUp main %}. Results</h2>
Learning Path
Beginner:
- Variables - Basic placeholders
- Invoice Tutorial - Your first complete template
- Iteration Patterns - Working with lists
Intermediate:
- Data Binding - Complex data structures
- Filters & Tags - Formatting and logic
- Conditional Content - Dynamic sections
Advanced:
- repeat() Function - JSONPath iteration
- Content Blocks - Reusable components
- Localization - Multi-region support
Common Tasks
| Task | Solution |
|---|---|
| Display JSON data | {{ variable }} or {{ object.property }} |
| Loop through array | {% for item in items %}...{% endfor %} |
| Format currency | {{ price \| format_number: "C" }} |
| Format date | {{ date \| parse_date \| date: "%Y-%m-%d" }} |
| Show if exists | {% if variable %}...{% endif %} |
| Show if empty | {% if items.size == 0 %}...{% endif %} |
| Add page numbers | {{tt_pageNumber}} in PDF header/footer |
| Number sections | {% secUp sectionName %} |
| Generate QR code | {{ qrCode(content) }} |
| Reuse components | {{ contentBlock(id, compId, scope) }} |
See Also
- Debugging - Troubleshooting tips
- Liquid Reference - Complete syntax guide
- Functions - Advanced features