Reusing Code Across Multiple Pages

Last updated on April 06, 2026.

Partials are reusable code snippets that you extract into separate files to keep your templates clean and DRY (Don't Repeat Yourself). They live in the directory and can contain HTML, Liquid, CSS, or JavaScript.

Using Partials

Include a partial in a page or layout using the tag. The path resolves relative to .

Passing Variables to Partials

Partials have their own variable scope. Pass data into a partial using named parameters:

Inside the partial, and are available as local variables.

Function Tag

Use the tag when you need a partial to return a value rather than render HTML:

The partial uses the tag to return its result. This pattern is ideal for data-fetching helpers and business logic that should not produce HTML output.

Organizing Partials

A common directory structure groups partials by purpose:

You can also manage partials through the Instance Admin. Navigate to CMS > Partials to create and edit them. See the Instance Admin documentation on Partials for details.

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.