Tags
Liquid Include Tag
Using Include Tag
Liquid include tag embeds Shopify snippets with deprecated syntax.
Introduction to Liquid Include Tag
The Liquid include tag is a templating feature used in Shopify and other Liquid-based environments to embed snippets into a theme layout. However, it is important to note that the include
tag is deprecated in favor of the render
tag. Despite its deprecation, understanding the include
tag is beneficial for maintaining legacy code.
Basic Syntax of the Include Tag
The basic syntax for using the include
tag is straightforward. You specify the snippet you want to include by its filename, without the extension:
Using Variables with Include
Variables can be passed to the included snippet by appending them after the snippet name. This allows you to make the snippet dynamic and reusable:
Passing Multiple Variables
You can also pass multiple variables using the for
syntax or by creating a hash:
Understanding Include vs. Render
The include
tag is now deprecated, with the render
tag being the recommended alternative. The render
tag offers improved performance and variable scoping. It's advisable to transition to using render
for new projects and gradually update existing codebases.
Common Use Cases
Despite its deprecation, the include
tag is still useful for maintaining older Shopify themes. Common use cases include:
- Embedding product or collection snippets in a layout.
- Creating a modular theme structure for easy updates.
- Reusing code across different parts of a Shopify store.
Tags
- Previous
- Paginate Tag
- Next
- Render Tag