Stencil
Stencil CLI
Options and commands

Stencil CLI Options and Commands

This article is a comprehensive command reference for Stencil CLI, BigCommerce's powerful theme development and deployment tool. For installation instructions for your OS, see Installing Stencil CLI. For more information on BigCommerce's Stencil Theme Engine, see About Stencil. Continue reading below for detailed information on each Stencil CLI command and option.

⚠️

BigCommerce is currently sunsetting its node-sass fork in favor of the latest sass/node-sass (opens in a new tab). To ensure that your storefront is up to date, use the latest active or maintenance node version in Stencil CLI and use the CLI command to resolve incompatible SCSS directives, which can cause issues with the styling of your storefront. Your current production site will continue to function as designed, but all future updates will require you to address any SCSS compatibility issues with Node.js 20. This upgrade is necessary to ensure the security of our platform and that you are not running out-of-date packages that may expose your projects to additional security vulnerabilities.

Commands overview

The syntax to run a Stencil CLI command is as follows:

Stencil CLI command syntax
stencil COMMANDS [OPTIONS] <PARAMETERS>

Running stencil help outputs a full list of commands and their descriptions. For more detailed information and usage examples, click a link in the table below:

CommandDescription
initInteractively creates a .stencil file or secrets.stencil.json and config.stencil.json files (if using Stencil V3.1 release or later), which configures how to run a BigCommerce store locally.
startStarts up the BigCommerce storefront local development environment, using theme files in the current directory and data from the live store.
bundleBundles up the theme into a structured .zip file, which can be uploaded to BigCommerce.
pullPulls the configuration from the active theme on your live store and updates your local configuration.
downloadDownloads the theme files from the active theme on your live store, overwriting local files if desired.
pushBundles the theme into .zip file; then directly uploads the .zip to BigCommerce.
releaseCreates a new release in a theme's GitHub repository.
helpDisplays help and returns all the options available to use for the specified command.

Basic Stencil CLI Options and Commands

stencil help

Displays help and returns all options available for the specified command.

Usage: stencil help
stencil help COMMAND

 

Example: stencil help
~ $ stencil help
Usage: stencil [OPTIONS] COMMAND
 
Options:
  -V, --version  output the version number
  -h, --help     output usage information
...

stencil init

Creates a .stencil file or secrets.stencil.json and config.stencil.json files (if using Stencil V3.1 release or later) used to configure the live preview when stencil start is run. You can specify the configuration information using the optional switches; if you do not specify the configuration information via options, Stencil CLI will prompt you to do so.

NOTE: For custom templates, use only the config.stencil.json file. The config.stencil.json file contains theme-related configuration information like store URL, custom templates, etc. The secrets.stencil.json file contains the access token.

Usage: stencil init
stencil init [--url STORE_URL] [--token API_TOKEN]
OptionAliasDescription
--port HTTP_PORT-pThe HTTP port number to use when serving the live theme preview.
--token API_TOKEN-tThe BigCommerce API Token (opens in a new tab).
--url STORE_URL-uThe BigCommerce storefront URL.

stencil start

Starts the live theme preview using the theme files in the current directory.

Usage: stencil start
stencil start [-V|--version] [-o|--open] [-v|--variation] [-t|--test] [-t|--tunnel] [-vb|--verbose]
stencil start [-h|--help]

 

Example: stencil start
stencil start --open # opens live theme preview in default browser
OptionAliasDescription
--version-VOutput the version number
--open-oAutomatically open default browser
--variation NAME-vSet which theme variation to use while developing
--channelId CHANNELID-cSet the channel id for the storefront
--timeout-tSet a timeout for the bundle operation. Default is 20 secs
--tunnelCreate a tunnel URL that points to your local server, which anyone can use. The required password for external connections is your public IP address.
--no-cache-nTurn off caching for API resource data (cache refreshes every 5 minutes)
--verbose-vbEnable verbose logging
--help-hOutput usage information

--theme-editor and --theme-editor-port [port]:

BigCommerce deprecated -theme-editor and --theme-editor-port [port] options as of v1.23.1. Please use Page Builder instead.  

⚠️

Authentication errors

If you receive an Unauthorized, please use a valid username/token error, authentication has failed. Make sure the API token you supplied is correct. For more information on creating store API accounts and generating tokens, see Obtaining Store API Credentials.

stencil bundle

Bundles up the theme into a structured .zip file, which can be uploaded to BigCommerce.

Usage: stencil bundle
stencil bundle

stencil pull

Pulls the configuration from the active theme on your live store and updates your local configuration. This is useful if any theme settings have been changed within Page Builder, as it will prevent you from overwriting them with your next theme upload by first syncing them.

Usage: stencil pull
stencil pull [OPTIONS]
OptionAliasDescription
--host HOSTNAME-hSpecify the API host (default: api.bigcommerce.com)
--filename FILENAME-fSpecify the filename to use for the merged configuration (default: config.json)
--saved-sDownloads the most recently saved configuration instead of the live one.
--channel_id CHANNEL_ID-cSpecify the channel ID of the storefront, if the store has multiple storefronts.
--help-hOutput usage information
Example: stencil pull
stencil pull

stencil push

Bundles up the theme into a structured .zip file; then directly uploads (pushes) the .zip to BigCommerce.

Usage: stencil push
stencil push [<OPTIONS>]
OptionAliasDescription
--version-VOutput the version number
--host HOSTNAMESpecify the API host (default: api.bigcommerce.com)
--file FILENAME-fSpecify the filename of the bundle to upload
--save FILENAME-sSpecify the filename of the saved bundle
--channel_ids CHANNEL_ID-cSpecify the channel ID(s) of the storefront, if the store has multiple storefronts
--activate VARIATIONNAME-aSkip activation prompt; specify variation or leave blank to select first variation
-a -c {{channel_id_1 channel_id_2 ... channel_id_n}}Allows you to apply a theme to selected channels (at least one channel id should be provided)
-a -all_channels or a -allcAllows you to apply a theme to all available channels.
--delete-dDelete oldest private, non-active theme if upload limit reached
--help-hOutput usage information
Example: stencil push
stencil push -f Cornerstone-2.3.2.zip # uploads specified file, skips bundling if file already exists

--filename:

You can use the -f or --filename option in cases where you have already run stencil bundle to bundle your theme, but the resulting .zip file has not yet been uploaded to BigCommerce. Use the generated .zip file's filename as a parameter to identify the generated file in your theme directory. An example of the command is outlined below. When you run stencil push, you can apply one theme to multiple storefront or channels. When you run stencil push with the -f or --filename option, Stencil CLI skips all its bundling steps and diagnostics. It proceeds directly to uploading the specified file, displaying its processing progress bar to show upload status.

stencil download

Download the theme files from your live store, overwriting files in your local directory.

Usage: stencil download
stencil download [OPTIONS]
OptionAliasDescription
--host HOSTNAME-hSpecify the API host (default: api.bigcommerce.com)
--file FILENAME-fSpecify a single file to download from the theme, e.g. templates/layout/base.html
--exclude-eSpecify a directory to exclude from the download.
--channel_id CHANNEL_ID-cSpecify the channel ID of the storefront, if the store has multiple storefronts.
--help-hOutput usage information
Example: stencil download
stencil download -f package.json

stencil release

Creates a new release in a theme’s GitHub repository. Developers outside BigCommerce can use this for forks (not master) of Stencil’s Cornerstone base theme, or for their own parallel themes independent of Cornerstone.

Usage: stencil release
stencil release [OPTIONS]
OptionAliasDescription
--version-VOutput the version number
--help-hOutput usage information

Resources

Related Articles

Did you find what you were looking for?