Add a theme using SXA CLI
SXA CLI is a useful command line tool to automatize tasks for an SXA project. This topic describes how to add a theme using SXA CLI. This can be convenient if you want to have more control over your assets and use a version control system, such as Git.
To add a theme using SXA CLI:
-
Go to
Website\App_Config\Include\z.Feature.Overrides
and enable thez.SPE.Sync.Enabler.Gulp.config.disabled
file. -
Open a command prompt terminal and install the registry:
npm config set @sitecore:registry=https://www.npmjs.com/package
-
Use npm and the install command to install SXA CLI as a global package:
npm i -g @sitecore/sxa-cli
. -
Run
sxa register <url>
.For the
<url>
, enter the instance for which you want to create the theme. -
Run
sxa new <ThemeName>
.Optionally, you can enter the name of the new theme (
<ThemeName>
). -
Enter the theme path:
<Rootfoldername/Childfoldername>
. -
Enter answers to the questions prompted by npm. Questions include: login, password, theme name, theme path.
If you answer Yes to the question Do you want to set up theme config file?, the config file is automatically updated.
-
Change the directory to the folder that contains the new theme:
cd <ThemeName>
-
Run
npm i
. -
Your new theme is now available. Make sure to assign your new theme to your site:
Go to
Sitecore/Content/<tenant>/<site>/Settings
, and in the Site Configuration settings, in the Compatible themes field add your new theme to the Selected field. Now you can select the theme as your site's current theme.
The following table describes the most important commands for using SXA CLI in your theme setup:
Command |
Description |
---|---|
|
Runs the create theme pipeline and stores the theme both locally and in Sitecore. Use this command to create a new theme for your site. |
|
Sets up the theme variable by answering a list of questions. Use this command to change the theme setup. |
|
Globally registers an instance of Sitecore URL. |
|
Checks the currently registered URL. |
Video: Create a theme using SXA CLI
You can watch this video from the Discover Sitecore channel for a demonstration of how you can create a theme using SXA CLI: