Home > Articles > Creating A Shopify Theme From Scratch: The Most Detailed Guide

Creating A Shopify Theme From Scratch: The Most Detailed Guide

January 12, 2024
Written and researched by experts at AvadaLearn more about our methodology

By Sam Nguyen

CEO Avada Commerce

This guide will equip you with the essential steps and insights for Creating A Shopify Theme From Scratch, enabling you to craft a unique, engaging Shopify theme.

Creating A Shopify Theme: What to Know

Shopify’s Liquid – the Template Language 

The first step to creating a Shopify theme is understanding Liquid’s robust and flexible template language. For existing store owners, a basic grasp of Liquid allows for tweaking and customizing your music beyond the standard settings. For web developers and designers, mastering Liquid is an indispensable skill that enables the creation of dynamic, custom themes that meet specific client needs.

Understanding Theme Structure and Files 

Creating a Shopify theme isn’t just about writing code – it’s about understanding how that code translates to an online store’s visual and functional aspects. Theme files dictate everything from the site layout, typography, and color scheme, to the functionality of the shopping cart.

Basic Components of Shopify Themes 

Shopify themes include layouts, templates, sections, snippets, assets, and config files. Each plays a unique role in creating a seamless user experience. For Shopify store owners, familiarizing yourself with these components can help you better articulate your needs to developers or even DIY minor theme adjustments. For web developers, these components are the building blocks to craft tailor-made themes that perfectly align with client’s business goals.

Step-by-Step Guide to Creating a Shopify Theme

Begin Creating a Theme

You’re now prepared to start building a new theme. You may be wondering: What’s the fastest way to establish my development environment and initiate coding?

An essential step in this process is using the Shopify detector tool. This tool is beneficial to understanding what themes are used on the websites, offering valuable insights as you embark on your theme development.

In this guide, you’ll leverage Shopify CLI and Dawn to develop a new theme and upload it onto Shopify.

What You’ll Learn

By the end of this guide, you will have:

  • Established your local development environment
  • Duplicated Dawn, the reference theme provided by Shopify
  • Reviewed modifications made to your local code
  • Transferred the theme code to your Shopify store and launched your theme
creating-a-shopify-theme-1

Requirements

  • Before building a theme, we suggest setting up or logging into a Shopify Partner account and establishing a development store. It’s recommended to use a development store for this tutorial.
  • Ensure you have the URL of the store you plan to work on, such as johns-apparel.myshopify.com.
  • Also, check that you have a collaborator or staff account with either the ‘Manage themes’ or ‘Themes’ permission for the store you’ll be working on or that you are the store owner. 

Caution

To utilize a development store or Plus sandbox store with the Shopify CLI, you must either be the store’s owner or have a staff account on it. Your Partner staff account will automatically generate these staff accounts the first time you access a development store through the Partner Dashboard.

Setting Up Shopify CLI: What You Need to Know

The prerequisites to install and operate Shopify CLI vary depending on your operating system:

Operation system Requirements
macOS
  • Homebrew
  • Node.js 16 or higher
  • Ruby
  • Git
  • Note: When you install SHopify CLI using Homebrew, Homebrew installs Node.js, Ruby, and Git for you
Windows
  • Node.js 16 or higher
  • Ruby+Devkit 3.0, installed using RubyInstaller for Windows (select the MSYS2 component and the MSYS2 base installation option)
  • Git
  • Bundler 2.3.8 or higher
Linux
  • Node.js 16 or higher
  • Ruby 3.0
  • Ruby development environment (ruby-dev / ruby-devel)
  • Git
  • cURL
  • GCC
  • G++
  • Make

Step 1: Setting Up Shopify CLI

Shopify CLI, a command-line utility, is your ally in the quest of Creating A Shopify Theme. It facilitates local theme development by allowing you to preview, test, and share theme alterations. 

macOS (Homebrew)

creating-a-shopify-theme-2

Window and Linux  (npm)

To install Shopify CLI on macOS, Windows, or Linux, you must install the @shopify/cli and @shopify/theme Node.js packages globally using the command line.

creating-a-shopify-theme-3

Step 2: Kickstarting a New Theme with Dawn

Utilize the shopify theme init command to clone the Dawn Git repository to your local system. 

Dawn, Shopify’s reference theme, is optimized for performance, flexibility, and user-friendly experience. It serves as an excellent starting point for your theme creation journey.

Caution:

If you want to create a theme for the Shopify Theme Store, Dawn can undoubtedly serve as an initial reference. However, your final submitted theme must be significantly distinct from Dawn, providing users with added value. Explore the different ways in which you can utilize Dawn to your advantage.

Here are the steps:

  1. Open your terminal and navigate to your preferred working directory where you want to clone Dawn.
  2. Input the following command: [shopify theme init]
creating-a-shopify-theme-4
  1. You’ll be prompted to assign a name to your theme, such as [my-new-theme]. The theme will be cloned into a folder bearing the same name.
  2. Once the theme is cloned, navigate into the folder.
creating-a-shopify-theme-5

Tip

You can use the Shopify theme dev command to generate both a preview link and a link to the theme editor for the development theme. This image shows the initiation of a development server using the dev command.

Step 3: Activating a Local Development Server

Once you’ve initialized your theme, the shopify theme dev command can interact with the theme in a web browser. The Shopify CLI uploads your theme as a development theme to your store.

Running this command provides a URL that enables hot reloading of local CSS changes and section updates. This allows you to preview alterations in real time, utilizing the store’s data for an authentic experience. This real-time preview is exclusively available on Google Chrome.

The initial use of the dev command will prompt you to log in to Shopify.

  1. To start serving your theme, run the command as shown below. The –store flag represents the name of the store you want to use to preview your theme:
creating-a-shopify-theme-6

You’ll need to use the –store flag when you preview your theme for the first time. The store you specify will be used for subsequent commands unless you provide the –store flag with a new value. If you wish to verify which store you’re linked to, run shopify theme info.

  1. Head to http://127.0.0.1:9292 in Google Chrome to open your theme preview.

Tip

You can use the Shopify theme dev command to generate both a preview link and a link to the theme editor for the development theme. This image shows the initiation of a development server using the dev command.

The following image shows a development server being started using dev:

creating-a-shopify-theme-7

Step 4: Transfer Your Theme to Your Shopify Store

When you’re ready to share a permanent link to your theme, update your existing theme’s code, or prepare your theme for publication, you’ll need to transfer your theme code to Shopify. You can do this using the theme push command.

For the first time you perform this operation, you might want to upload the theme to your theme library as a new, unpublished theme. To do this, execute the command and the –unpublished flag. Upon running the command with this flag, you’ll be asked to provide a unique name for your theme that will be visible in the theme library.

creating-a-shopify-theme-8

After the theme is created, you can update your theme code by running the push command without any flags:

creating-a-shopify-theme-9

Step 5: Upload Your Theme To the Store

When you’re prepared to go live with your theme on your store, you can accomplish this by employing the theme publish command. Before you proceed with this command, you must ensure that all your local changes have been pushed to Shopify using the theme push command.

  1. To proceed, type in the following command: Shopify theme publish
creating-a-shopify-theme-10
  1. From the provided list, select the theme you wish to publish.
  2. When prompted for confirmation, select ‘Yes’ to verify your choice.

The theme is published and is now the active theme for the store.

Taking the Next Step in Your Theme Building Journey

Creating your first theme using our tools is a significant achievement, but it’s just the starting point in your theme-building journey. To expand your knowledge and skills, consider taking the following steps:

Getting to Know Shopify Themes

  • Uncover the Architecture of a Theme: For a more in-depth understanding, delve into the structure of a theme. Our architecture documentation can be a helpful guide, helping you understand the function of each file and folder within a theme.
  • Embrace Best Practices for Theme Design: Shopify themes are versatile and potent tools for creating excellent ecommerce experiences. To truly leverage their potential, building your theme following certain guiding principles is essential. We’ve compiled a list of best practices covering critical aspects such as performance, accessibility, and design.
  • Optimize Your Workflow: If your project involves collaboration with a team of developers or if you wish to employ build tools or advanced version control strategies, refining your workflow is necessary. Our collection of best practices can help you understand how these strategies can be integrated into your Shopify theme development process effectively.

Adding Features to Your Theme

As your theme creation progresses, you can incorporate various Shopify features or additional functionalities. These features span several categories:

  • Product Merchandising: Showcase your products in the best light and promote sales.
  • Pricing and Payments: Customize how pricing is displayed and payments are processed.
  • Delivery and Fulfillment: Improve customer satisfaction with efficient order delivery and fulfillment processes.
  • Customer Engagement: Boost your customer interactions with features designed to increase engagement.
  • Shopify Markets: Capitalize on Shopify’s global marketplace and expand your reach.
  • Site Navigation and Search: Enhance the user experience with easy navigation and efficient search options.
  • Search Engine Optimization: Improve your site’s visibility with SEO tools.
  • Trust and Security: Establish customer trust and maintain a secure transaction environment.

If you’re crafting a theme for a client’s store or your own, you can choose from these features according to your specific needs. However, if your goal is to create a theme for the Shopify Theme Store, you’ll need to ensure that some of these features are incorporated into your theme per the guidelines.

Diving Deeper into Theme Tools

As you continue your theme creation journey, specific tools are available to help you refine and optimize your work. Here’s how to leverage them:

  • Enhance Code Quality with Linting: Use the Theme Check tool, a linter designed for Liquid and JSON. This tool can help you spot and fix errors while ensuring your theme aligns with Shopify’s best practices for theme and Liquid development.
  • Leverage Shopify GitHub Integration: This integration enables automatic code syncing between a GitHub repository and your Shopify store. It provides an efficient way to develop, test features, and collaboratively monitor changes made in the Shopify admin. Setting this up will streamline your development process significantly.

Distribute Your Theme

Once you’ve crafted your theme, it’s time to share it with the world. Here are a few steps to get you started:

  • Submit Your Theme to the Shopify Theme Store: As a theme Partner, you can extend your reach to a global audience of millions of entrepreneurs. It’s essential to familiarize yourself with the specific requirements for themes in the Shopify Theme Store before submission.

Note of Caution: While you can use ‘Dawn’ as a foundation for your Shopify Theme Store submission, remember your theme must be significantly different and offer more value to the users. Find out more about the different ways to use ‘Dawn’.

  • Handing Off Your Theme to a Client: If your theme is client-specific, check out our guidelines on best practices when working with merchants to ensure a smooth handover process.

5 Common Pitfalls to Avoid When Creating a Shopify Theme

Neglecting Mobile Responsiveness

Mistake: Overlooking the importance of a mobile-friendly design.

Solution: Ensure your theme is responsive and provides a seamless experience across all device types. Regularly test your theme on different devices and screen sizes.

Ignoring SEO Best Practices

Mistake: Not optimizing your theme for search engines.

Solution: Incorporate SEO best practices from the start, like using meta tags, alt attributes for images, and creating a user-friendly URL structure.

Overloading With Features

Mistake: Adding too many features and elements makes the site heavy and slow to load.

Solution: Strike a balance between functionality and performance. Only include necessary features and regularly check your site’s load time.

Failing to Implement a User-Friendly Design

Mistake: Focusing solely on aesthetics at the expense of usability.

Solution: Prioritize user experience in your design. Navigation should be intuitive, and essential elements like product details and the “Add to Cart” button should be easy to find.

Overlooking Shopify’s Liquid Templating Language

Mistake: Ignoring the power and capabilities of Shopify’s Liquid language.

Solution: Invest time to understand and leverage Liquid. It allows you to create dynamic and personalized content, enhancing the user experience.

Bottom Line

Creating a Shopify theme from scratch requires a solid understanding of Shopify’s infrastructure, especially Liquid, and a focus on user experience and SEO. However, when done right, a custom theme can significantly enhance your store’s engagement, improve branding, and drive sales growth.


Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.