All Tutorials

Create alternate templates

All Tutorials

Create alternate templates

Create alternate templates

Creating an alternate template allows you to modify the way content is shown on your online store, but only for the products, collections, blogs, and other pages that you apply the alternate template to. For example, you can create an alternate product template that has no add to cart button, and apply it only to products that are not for sale. Or, you can create an alternate page template that doesn’t include a header, and apply it to a selection of your store’s pages.

Create a new template file in your theme

  1. In the Templates directory, click Add a new template.

  2. Choose a type option for your new template. For example, for an alternate product template, select product. Give your template a meaningful name, which will make it easy to find when you are assigning it in the admin. For example, an alternate product template with no prices or add to cart button might be called not-for-sale.

  3. Click Create template. Your new template will open in the code editor, and the file will be populated with default code.

  4. Edit your new template as needed.

  5. Click Save.

Create a new section in your theme

Depending on your theme and the type of template that you have created, you might need to create a new section.

If your new template includes a Liquid tag for a section that contains the code that you want to edit, then you'll need to create a new section. For example, if you are creating an alternate product template, then you'll need to create a new section, since most of the code that makes up the product page is stored in a section file, rather than a template file.

If your new template contains all of the code that you want to edit, then creating a section isn't necessary. In this case, you can edit your new template as needed, and move on to the final step.

  1. In your new template file, find the Liquid tag for the section that you'd like to edit, and replace the name of the section with the name that you'll give your new section. For example, the product template contains the following Liquid tag:

    {% section 'product-template' %}
  2. Replace product-template with the name of the new section that you will create next. For example, if you call your new section product-not-for-sale-template, then your code should look like this:

    {% section 'product-not-for-sale-template' %}
  3. Click Save.

Create a new section file in your theme

  1. In the Sections directory, click Add a new section. Give your section the same name that you used in the Liquid tag for your new template file:

  2. Click Create section. Your new section will open in the code editor, and will be populated with some default code.

  3. Delete the default code so that the file is empty.

  4. Copy and paste code into your new section file from an existing section in your theme. For example, if you're creating an alternate product template, then click to open product-template.liquid and copy the entire contents of the file. Return to your new and empty section file, and paste in the code that you copied.

  5. Edit your new section file as needed.

  6. Click Save.

Assign your template in the admin

After you have created an alternate template, it will appear in your admin. You will see a Theme templates section in the sidebar of the appropriate admin page. For example, if you have created a new product template, a Theme templates section will be visible when you click to view, create, or edit a product. You can assign the template that you want to use for each product from the Template suffix list.