Theme tags

Theme tags have many functions, including:

  • Outputting template-specific HTML markup
  • Telling the theme which layout and snippets to use
  • Splitting a returned array into multiple pages.

comment

Allows you to leave un-rendered code inside a Liquid template. Any text within the opening and closing comment blocks will not be output, and any Liquid code within will not be executed.

echo

Outputs an expression in the rendered HTML. This is identical to wrapping an expression in {{ and }}, but works inside liquid tags and supports Filters.

form

Creates an HTML <form> element along with the required <input> elements to submit the form to a particular endpoint.

form types and tag parameters

There are many types of forms that can be created and submitted in Shopify themes. Adding a product to the cart, creating a customer account, and commenting on a blog article all require <form> elements with different attributes and <input> elements.

To create different forms, the {% form %} tag requires a type and might require additional parameters. For example, the form used to submit a comment on a blog article requires the type of new_comment and needs an article object as a parameter.

The different form types and their required parameters are listed below.

activate_customer_password

Generates a form for activating a customer account on the activate_account.liquid template.

contact

Generates a form for submitting an email through the Liquid contact form.

customer

Generates a form for creating a new customer without registering a new account. This form is useful for collecting customer information when you don't want customers to log in to your store, such as building a list of emails from a newsletter signup.

To generate a form that registers a customer account, use the create_customer form.

create_customer

Generates a form for creating a new customer account on the register.liquid template.

customer_address

Generates a form for creating or editing customer account addresses on the addresses.liquid template. When creating a new address, include the parameter customer.new_address. When editing an existing address, include the parameter address.

customer_login

Generates a form for logging into Customer Accounts on the login.liquid template.

guest_login

Generates a form on the login.liquid template that directs customers back to their checkout session as a guest instead of logging in to an account.

localization

Generates a form for customers to select their preferred country so they're shown the appropriate language and currency. Inside the form, you can build two different selectors:

Country selector

You can create a country selector using the available_countries and country attributes of the localization object. Making a selection will update to the currency associated with the selected country, and if the currently selected language is not available, then it will be updated to the selected country's default language.

For example:

Language selector

You can create a language selector using the available_languages and language attributes of the localization object.

For example:

new_comment

Generates a form for creating a new comment in the article.liquid template. Requires the article object as a parameter.

product

Generates a form for adding a product variant to the cart. Requires a product object as a parameter.

recover_customer_password

Generates a form for recovering a lost password on the login.liquid template.

reset_customer_password

Generates a form on the customers/reset_password.liquid template for a customer to reset their password.

storefront_password

Generates a form on the password.liquid template for entering a password-protected storefront.