Post

Deploy Theme with Shopify CLI

Shopify CLI (Command Line Interface) is a set of tools provided by Shopify that allows developers to interact with their Shopify stores using the command line. It facilitates various tasks related to theme development, app development, and store management.

Benefits of deploying your theme with Shopify CLI include:

  1. Efficiency: Shopify CLI streamlines the theme development process by providing commands for tasks such as creating, updating, and managing themes. This increases development efficiency.

  2. Local Development: Developers can use Shopify CLI for local theme development, enabling them to work on themes offline and push changes to the live store when ready.

  3. Collaboration: Shopify CLI supports collaboration among developers by allowing them to share and synchronize their work easily. This is particularly useful for teams working on a common theme.

  4. Automated Deployment: With Shopify CLI, you can automate the deployment of themes, reducing the risk of errors and ensuring a smoother transition from development to production.

  5. Version Control Integration: It integrates well with version control systems (e.g., Git), allowing developers to track changes, collaborate effectively, and manage different versions of the theme.

  6. Quick Setup: Shopify CLI simplifies the setup process for new themes, reducing the time and effort required to create a new theme from scratch or set up an existing theme locally.

  7. Theme Preview: Developers can use Shopify CLI to preview their theme changes before making them live, helping to catch issues and ensure a seamless user experience.

In summary, Shopify CLI enhances the development workflow for Shopify themes, providing a more efficient and collaborative environment. It is a valuable tool for developers looking to streamline their theme development process on the Shopify platform.

Prerequisites

On your local system, cd into your local site folder.

1
cd my_shopify_site_files/

Logout

logout of the current session if you are not 100% certain of your current logged in account

1
2
shopify logout

Login to your site using shopify cli

1
shopify login --store=https://example.myshopify.com

A browser will launch and you need to choose the associated shopify account to login with.

Pull theme down to local files with cli

Pull all settings and content updates from remote server from the current live theme.

  • A list of themes will be returned
  • Choose the first one in the list if you want the live theme pulled
1
shopify theme pull

Deploy theme with cli

1
shopify theme push

You will be given the option of what theme you want to deploy to. This is a handy feature as it allows you to test your changes on one of the backup instances of your theme before deploying to the live theme.

Partial deploy - only deploy one file

1
shopify theme push --only assets/styles.css.liquid --allow-live`

Deploy to unpublished theme

If you omit the --allow-live flag, you will be asked which theme you want to deploy to. This can be handy for doing tests on unpublished themes using the theme preview mode to preview the your deployments first before deploying to the published theme.

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.