Advanced Shopify theming techniques you should be using

I have been working on Shopify themes for the past few years, and now as a designer advocate at Shopify, I have learned countless tips, tricks, and hacks that you can use to reinvigorate your theme design process and, ultimately, make your workflow more efficient. This article will provide you with an overview of several advanced theme development techniques that I have been using recently. I’ll also include code samples and resources that you will find useful when you’re building your next theme on Shopify.

I like to think of Shopify theme development as a blank canvas. Shopify gives you the tools to design and develop beautiful stores using toolsets that you already know like HTML, CSS, and Javascript. The only new element you will need to familiarize yourself with is Liquid. Liquid is the Shopify template language that allows you to use placeholders to pull data from a store into your theme. It’s quick to learn and I recommend you bookmark the very useful Liquid cheat sheet to help you get up and running quickly.

Setting up a Shopify theme development environment

When I start designing and developing a new Shopify theme, the first thing I do is set up a development store in my Shopify Partner dashboard. Setting up a Shopify Partner account will give you access to an unlimited number of development stores. Development stores never expire and provide you with all the features of a fully paid store. Shopify has a online editor for theme development, but my preference is to work on themes locally because I can use Atom – my code editor of choice. If you’d like to set up a local theme development environment as well, you can check out the how-to article I wrote recently.

As a designer advocate, I get to connect with many great designers and developers and see first hand what works well for them, and what doesn’t. One thing that I’ve noticed is how time is often wasted while setting up placeholder content for a store before the design and development process can even begin. To help with this I recently released a toolkit which consists of product data and images. You can use these to set up a fully loaded store with just a few clicks. This will help save you valuable hours and will allow you to make better design decisions. This real-world product data gives you the context needed to accurately see what the final result will look like.

Brief Liquid overview

If you’re new to Liquid, don’t be intimidated. My own background is in design with some front-end knowledge, yet I now teach others how to use it. Put simply Liquid allows designers to use placeholders within their HTML which when requested will be replaced with live store data. Here’s a quick overview of the key elements:

Output – Uses the {{ }} syntax and allows you to pull textual data from a store. A good example is {{ product.title }} which will be replaced with the title of a product entered via the Shopify admin

Logic – Uses the {% %} syntax and allows the use of if statements and more. This is very useful when you want to show certain parts of a page dependant on a particular condition. For example, if a product is sold out

Filters – These are denoted via the | character and allow you to manipulate your output. A simple example is {{ 'i want this to be uppercase' | upcase }} which will take the text on the left and output it in uppercase

You can find out more and learn more advanced features of Liquid by watching this presentation.

Now that we’ve got a basic understanding of Liquid, let’s take a look at five advanced theming techniques that you can add to your workflow. If you have any problems following along as we move through these techniques, we have a lot of educational resources that you will find helpful.

Advanced theme technique 01: dynamic product type tags

Dynamic product type tags are a great way to improve the buying experience in your client’s store. Dynamic product type tags make it easy for buyers to click on a product type and browse similar products.

For example, if a customer clicks on jackets, the buyer will be taken to a collection that lists all of the jackets available. This is powerful because the jackets in the store did not have to be manually sorted into a jackets category. The sorting and collection is all done for you in the background.

The following code sample will create a clickable dynamic product type tag. Upon clicking the associated product tag, buyers will be taken to a page where they can browse all of the similar products available on the store.

Advanced theme technique 02: customizable line properties

If you would like to request information from a buyer, such an engraving details, you can add a line-item property box to your product page to request that information. Just insert the following code sample to add a line-item property to any product page:

The line-item property information will be saved on the ‘notes’ field in the customer’s order. You can find out more about how to customise product pages in the Shopify Docs.

Advanced theme technique 03: snippets

Snippets help us reuse and repurpose lines of code, and they also help us organize long templates into just a handful of snippets. If you have worked with PHP in the past, snippets works similarly to PHP includes.

Snippets are created in the 'snippets' folder of a Shopify theme, and the name given to the snippet will be the name we use to reference the snippet and include it in our liquid file.

For example, the following code snippet will return a list of five related products and can be reused on other liquid templates:

The snippet will be called ‘related-products.liquid’, and we can include the snippet in our ‘product.liquid’ file as follows:

{% include related-products %}

We can include this snippet in multiple files. If we make a change to the snippet this will be reflected in every file that references it. Being clever with snippets will make your template files easier to read and your workflow more streamlined.

Advanced theme technique 05: metafields

Metafields can help you extend the functionality of online shops by giving you the ability to add additional information to products, collections, orders, blogs, and pages. Using Liquid, you can then display the additional metafield information on storefronts.

Metafields have four components: namespace, key, value, and a description (optional). Namespaces will be used to group different metafields, keys will be used to reference our information, and values will contain our unique content. We can also specify if the value is a string or integer.

Metafields are a very powerful tool. To make working with them easier I recommend installing a bookmarklet tool for Google Chrome called ShopifyFD.

From novice to pro

If you would like to try out these Liquid techniques for yourself, all you need to do is set up a Shopify development store by signing up to the free Shopify Partner program. I regularly create test stores to try out new ideas and concepts and I strongly recommend that you do the same.