Templates control what's rendered on each type of page in a theme.
Each page type in an online store has an associated template type. You can use the template to add functionality that makes sense for the page type. For example, you can add additional product recommendations to a product template, or add a comment form to an article template.
You can create multiple versions of the same template type to create custom templates for different use cases. For example, you can create a separate product template for outerwear products, or a separate page template for pages with video content.
Template files are located in the
templates directory of the theme:
You can use two different template file types in your theme. These template file types can be used to build multiple template types, each of which represents a type of content in a merchant's online store.
There are two different file types you can use for a theme template: JSON and Liquid.
Some template types support only the Liquid file type, while other template types support either template file type.
|JSON||JSON templates are data files with the
If you're using a JSON template, then any HTML or Liquid code needs to be included in a section that's referenced by the template.
To learn more, refer to JSON templates.
|Liquid||Liquid templates are Liquid markup files, with the
JSON vs. LiquidAnchor link to section titled "JSON vs. Liquid"
If you want to use sections in a template, then you should use a JSON template.
JSON templates provide more flexibility for merchants to add, remove, and reorder sections, including app sections. Additionally, they minimize the amount of data in settings_data.json. Instead, data is stored directly in the template, which improves the performance of the theme editor.
Template typesAnchor link to section titled "Template types"
Each available template type represents a type of content in a merchant's online store. No template types are required. However, you must have a matching template for any page type that you want to render. For example, to render a product page, you need at least one template of type
You can have a maximum of 1000 JSON templates in your theme, across all template types. For example, if you have 20 JSON product templates, 10 JSON page templates, and 5 JSON collection templates, then you can add up to 965 additional templates to the theme.
You can use the following template types in your theme. To learn more about each template type, click on the template name.
|404||Renders page content that is shown to customers if they enter an invalid URL for the store.|
|article||Renders the article page, which contains the full content of the article, as well as an optional comments section for customers. This template is used for items like individual posts in a blog.|
|blog||Renders the blog page, which lists all articles within a blog.|
|collection||Renders the collection page, which lists all products within a collection.|
|customers/account||Renders the customer account page, which provides an overview of the customer’s account.|
|customers/activate_account||Renders the customer account activation page, which hosts the form for activating a customer account.|
|customers/addresses||Renders the customer addresses page, which allows customers to view and manage their current addresses, as well as add new ones.|
|customers/login||Renders the customer login page, which hosts the form for logging into a customer account.|
|customers/order||Renders the customer order page, which displays the details of a customer’s past orders.|
|customers/register||Renders the customer register page, which hosts the form for customer account creation.|
|customers/reset_password||Renders the password reset page, which hosts the form to reset the password for a customer account.|
|gift_card.liquid||Renders the gift card page, which displays the gift card issued to a customer upon purchase.
This must be a Liquid template.
|index||Renders the home page of the store, located at the root URL (
|list-collections||Renders the collection list page, which lists all the store's collections. This page is located at the
|page||Renders the shop’s pages, such as About us and Contact us.|
|product||Renders the product page, which contains a product's media and content, as well as a form for customers to select a variant and add it to the cart.|
This must be a Liquid template.
A Liquid template doesn't have a fixed schema. Refer to Content for information about what you can include in a Liquid template.
A JSON template accepts only a JSON file with a fixed schema and list of accepted attributes. For information about the schema of a JSON template, refer to JSON templates.
The content that you can include in a template depends on whether it is a JSON template or a Liquid template.
You should always keep the goal of the template type in mind when deciding what content you want to include in a template. For example, a product template, or a section in the product template, should always include the product object, which renders product details, and the product form tag, which lets customers add a product variant to the cart. Depending on your template type and approach, you might want to include these items in a section that you reference in the template.
A Liquid template accepts standard HTML and Liquid. Liquid templates can access any global Liquid objects, as well as the object that's associated with the template. For more information, refer to the documentation for each template type.
A JSON template accepts only JSON with a fixed schema and list of accepted attributes. For more information, refer to JSON templates.
When working with template files, you should familiarize yourself with alternate templates and how to use them.
Alternate templatesAnchor link to section titled "Alternate templates"
In some cases, you might need to create different markup for the same template. For example, you might want to create an alternate template that includes different sections for specific products.
You can create an alternate template locally, through the theme code editor, or through the theme editor.
Name structureAnchor link to section titled "Name structure"
Alternate template files use the following name structure, where
template-name is the template name,
template-suffix is the alternate name, and
template-file-type is the file type, which is either
For example, if you create an alternate JSON product template with the name of alternate, then the file name would be the following:
Use an alternate templateAnchor link to section titled "Use an alternate template"
After an alternate template has been created, it can be applied in the following ways:
- It can be assigned to an associated resource in the Shopify admin.
- It can be previewed in the theme editor.
- It can be rendered on the storefront with the
Render an alternate templateAnchor link to section titled "Render an alternate template"
Alternate templates can be rendered on the storefront with the
view URL parameter. This parameter should be in the format of
[template-suffix] is the template's alternate name.
For example, given the
product.alternate.json template from the previous section, and a product called Example product, you can render that product with that template using the following: