Snippets
Snippets are reusable pieces of Liquid code that help maintain consistency and reduce duplication across your theme.
Overview
- Not visible in the theme editor
- Ideal for code that’s repeated throughout your theme
- Can be thought of as “components” or “partials”
- Can be created, deleted, or renamed as needed
Creating Snippets
Snippets are stored in thesnippets/ directory with a .liquid extension. For example:
Using Snippets
To include a snippet in a section or another snippet, use therender tag:
Passing Variables to Snippets
You can pass variables to snippets when rendering them:Default Values
You can provide default values for snippet variables using thedefault filter:
Common Snippet Use Cases
UI Components
- Buttons
- Cards
- Navigation elements
- Progress bars
Content Patterns
- Course listings
- Module layouts
- Lesson previews
- User information displays
