Version control for Shopify themes (2024)

When you build a Shopify theme, you can introduce optional version control to track and manage changes to your theme code. Version control helps you to manage changes to your code over time.

The Shopify GitHub integration lets you add version control to themes in a Shopify store. When a theme is connected to a GitHub repository using the Shopify GitHub integration, any changes that a merchant makes to the theme are tracked as commits to the branch.

You should consider the following factors when planning a version control strategy for a Shopify theme:

  • Branch organization and publishing strategy - Because the GitHub integration lets you develop features and campaigns using branches, you should consider how you want to organize your branches and manage your published theme.
  • Managing source and compiled code - The Shopify GitHub integration only supports the default Shopify theme folder structure. If you use a build pipeline to transform your theme's source code into compiled code, then you need to choose an approach that allows you to use a build pipeline, but also lets you track and manage changes to compiled code using the GitHub integration.

Branch organization

Anchor link to section titled "Branch organization"

If you're using the Shopify GitHub integration to develop your theme, then consider connecting your main or master branch to your store and then publishing the resulting theme. This ensures that the published theme is always up to date with features as they are merged to the main or master branch.

For events like sales, consider using non-main branches to customize your theme. Themes connected to these branches can be published temporarily. After the event is over, you can republish the theme that's connected to your main branch.

If you use a build pipeline to transform your code, then you should create a specific deploy branch that acts as your main production code branch, and then deploy the code that you compile off of master to this branch. To learn more, read about managing source and compiled code in the next section.

Managing source and compiled code

Anchor link to section titled "Managing source and compiled code"

You might use a build pipeline to transform your theme's source code into compiled code that's optimized for browser runtime. Because the Shopify GitHub integration supports only branches that match the default Shopify theme folder structure, you need to organize your code so that a branch that's connected to Shopify matches this structure. For example, a branch that's connected to Shopify can't contain src and dist folders.

You can choose from several strategies to manage both your source and compiled code in version control:

  • Use separate repositories for source code and compiled code
  • Separate source code and compiled code using branches (recommended)
  • Mix source code and compiled code
  • If you don't want to track your theme code using the Shopify GitHub integration, then you can also choose to manage only your source code in version control.

Advantages to managing your source and compiled code using version control

Anchor link to section titled "Advantages to managing your source and compiled code using version control"

Managing your source and compiled code using version control has the following advantages:

  • You can leverage common build tools such as Webpack, Rollup, and PostCSS.
  • Files can be incrementally built on the developer's machine, which allows for live previews of changes made to source code.
  • Changes to compiled code via Shopify can be easily identified.
  • You can push changes to compiled code to the store using the Shopify GitHub integration.

However, using this model, changes made to compiled code need to be manually backfilled into the source code.

Use separate repositories for source code and compiled code

Anchor link to section titled "Use separate repositories for source code and compiled code"

A developer can have one repository that contains their source code and build tools, and another repository that contains a versioned representation of their compiled code.

Advantages

Anchor link to section titled "Advantages"

  • Using separate repositories is easy to adopt when moving from a source-only versioning model. You can continue to push compiled code directly to a store, and then use the Shopify GitHub integration to track changes to your compiled code over time.

Disadvantages

Anchor link to section titled "Disadvantages"

  • You need to work across two repositories for a single theme, which can make backfilling source code more complex.
  • Static files that aren't impacted by file transformations are copied between repositories, resulting in extra maintenance and backfilling.

Separate source code and compiled code using branches (recommended)

Anchor link to section titled "Separate source code and compiled code using branches (recommended)"

You can publish the compiled code for a theme in a separate branch from the source code. The contents of this branch are compatible with the Shopify theme platform and Theme Check.

One way to accomplish this is by using git subtree. Using the subtree command, you can extract your compiled code to a branch that can then be safely connected to a theme.

Advantages

Anchor link to section titled "Advantages"

  • There is a distinct location within your repository for your production code.
  • The commit history of the branch is clean. The only commits in the production branches are updates to production code. Changes to source code stay in their own branches.

Disadvantages

Anchor link to section titled "Disadvantages"

  • Previewing the contents of a working branch requires another branch that contains the "preview" production code. Managing branches might become cumbersome.
  • Static files that aren't impacted by file transformations reside in separate branches, resulting in extra maintenance and backfilling.

Mix source code and compiled code

Anchor link to section titled "Mix source code and compiled code"

You can mix compiled code files within the same folder structure as the source code. For example, inside of an assets folder, you can add a main.js source file and a compiled main.min.js.

Advantages

Anchor link to section titled "Advantages"

  • Mixing source and compiled code minimizes the number of compiled files to only those that need to be compiled. This means that a merchant's changes to non-compiled files don't need to be backfilled or backported to your source code.

Disadvantages

Anchor link to section titled "Disadvantages"

  • Compiled code might be hard to identify, and merchants might edit it directly.
  • If edits are made to compiled code, then they need to be backfilled to avoid being lost the next time the code is compiled from its source.

Manage only your source code in version control

Anchor link to section titled "Manage only your source code in version control"

You can choose to commit only your source code to version control, and then deploy compiled code directly to a store when you want to create a release. Deployment can be done manually from a developer's machine using Shopify CLI, or automated using continuous integration.

Advantages

Anchor link to section titled "Advantages"

  • This approach is well supported in the Shopify theme developer community.
  • It can leverage common build tools such as Webpack, Rollup, and PostCSS.
  • Files can be incrementally built on the developer's machine, which allows for live previews of changes made to source code.

Disadvantages

Anchor link to section titled "Disadvantages"

  • Because the repo only contains source code that isn't compatible with the Shopify theme platform, this method isn't compatible with the Shopify GitHub integration.
  • Compiled code isn't version controlled, which makes tracking changes difficult. You need to manually identify changes to the compiled code, and then backfill your source code so that changes persist the next time the code is compiled and the theme is overwritten.
Version control for Shopify themes (2024)

FAQs

Version control for Shopify themes? ›

When you build a Shopify theme, you can introduce optional version control to track and manage changes to your theme code. Version control helps you to manage changes to your code over time. The Shopify GitHub integration lets you add version control to themes in a Shopify store.

How to update theme version in Shopify? ›

Manually update your theme. To add an updated version of your theme to your theme library, click the notification to open the details dialog, and then click Add to theme library. You can also click View release notes to read about the new theme release.

What version is my Shopify theme? ›

Theme versions are now listed for each theme in the Online Store portion of your Shopify admin. The version number is displayed here with two decimal points (e.g. Turbo 7.1. 1).

How do I manage themes in Shopify? ›

Android
  • From the Shopify app, tap the … button.
  • In the Sales channels section, tap Online Store.
  • Tap Manage all themes.
  • Find the theme that you want to edit, and then tap Customize.
  • Tap Edit.
  • Click Theme settings.
  • Click Inputs.
  • Use the sliding scales to change the appearance of your input Border.

How do I optimize my Shopify theme? ›

Consider the following best practices for optimizing the performance of your theme.
  1. Optimize your JavaScript. ...
  2. Preload key resources, defer or avoid loading others. ...
  3. Host assets on Shopify servers. ...
  4. Use responsive images. ...
  5. Optimize Liquid code. ...
  6. Use Theme Check to identify performance issues.

Do Shopify themes update automatically? ›

I've been told this can take several hours with non-supported themes. Where supported themes are automatically updated by Shopify with no action/time needed from owner.

How do I update my Shopify theme without losing content? ›

How to update your Shopify theme without losing customization
  1. Step 1: Backup your Shopify theme. Backing up your theme is the first thing that needs to be done. ...
  2. Step 2: Update your Shopify theme. ...
  3. Step 3: Customize your upgraded theme. ...
  4. Step 4: Test that your newly updated Shopify theme works.

What is Shopify latest version? ›

29th June 2021 brought one of the most noteworthy updates when Shopify launched its latest version 2.0. With over 4.4 million eCommerce websites hosted on Shopify, the upgrade bolsters its position as the market leader in eCommerce CMSes. The new features also set in motion some major opportunities for online brands.

How do I change the current theme in Shopify? ›

Changing your current theme in Shopify
  1. Step 1: Navigate to Online Store > Themes. In your Shopify dashboard, go to Online Store > Themes to see your Current theme and the fresh new theme in your Theme library. ...
  2. Step 2: Find your new customized theme and preview. ...
  3. Step 3: Publish your new theme.
May 6, 2023

Where is Shopify theme editor? ›

Access the theme editor

From your Shopify admin, go to Online Store > Themes. Next to the theme that you want to edit, click Customize.

What happens if I change my Shopify theme? ›

It's important to keep a record of any edits you've made to your store's template files. While you won't lose your navigation, pages, blog posts, products, or collections by changing your theme, you will lose any revisions made to your Edit HTML/CSS and Customize theme pages.

Where is Shopify theme library? ›

In your Shopify admin, click Online Store > Themes. In the Theme library section, click the ... button to open the actions menu next to the theme that you want to preview.

What is the most popular theme in Shopify? ›

Dawn. Dawn is one of the most popular Shopify themes because of its minimalist style, which lets your product images take center stage. It's ideal for apparel and fashion luxury brands. With its media-forward product, you can use large images to showcase your products.

Is Shopify theme worth it? ›

While free themes are a great place to start, you may need to invest in additional apps or hire a designer/developer to customize them. Investing in a paid theme can save you time and money in the long run as it can provide you with the extra features you need without additional add-ons.

How do I update my Shoptimized theme? ›

Navigate to Shopify Admin Page -> Apps -> Shoptimized Theme App -> Theme Updater.
  1. If your live theme is on latest version it would display: "Theme is up to date"
  2. Otherwise, it would display: "New Version Available"
  3. Please wait a few minutes and you're good.

How do I update variant in Shopify? ›

Steps:
  1. From the Shopify app, go to Products > All products.
  2. Tap the product that you want to edit.
  3. In the Variants section, tap XX variants.
  4. Tap the variant that you want to edit.
  5. Edit your variant details, such as options, pricing, inventory, and shipping.
  6. Tap ✓.

Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 6221

Rating: 5 / 5 (80 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.