Let’s Talk

We would love to hear from you. Want to know more about
our services or have any questions? Say Hi!

Deploying XM Cloud: Static Site Deployment with Netlify CLI

November 17, 2023
Deploying XM Cloud: Static Site Deployment with Netlify CLI
Keyur Garala
Keyur Garala
Sitecore Certified Solutions Architect

Netlify and Vercel are two prominent competitors in the JamStack industry. These cloud-based platforms provide hosting for Server Side Rendering (SSR) and Static Site Generation (SSG), which have recently gained popularity. When deciding between the two platforms, it becomes challenging as they offer similar features and functionalities.

To begin, ensure that you have the following:

  1. Access to an instance of Sitecore XM Cloud (refer to XM Cloud for details).

  2. A repository of GitHub for XM Cloud instance.

  3. A free account on the Netlify UI platform: Netlify UI.

By utilizing these platforms, you can explore and compare the offerings of Netlify and Vercel for your JamStack needs.

Netlify deployment

To connect to the XM Cloud environment, follow these steps:

Take note of the environment ID that contains the site you intend to deploy. Next, we need to identify the environment variables required for deploying our site on Netlify. These variables include:

  1. GRAPH_QL_ENDPOINT: Set this to the XM Cloud edge URL, which can be something like "https://edge.sitecorecloud.io/api/graph/v1".

  2. JSS_APP_NAME: Specify the Site name in Sitecore.

  3. PUBLIC_URL: The value for this variable will be generated when you set up your site in Netlify. It represents the URL where your site will be accessible.

  4. SITECORE_API_KEY: To generate the access token, you can use the "New-EdgeToken.ps1" script found in the repository mentioned above.

By configuring these environment variables in Netlify, you'll be able to deploy your XM Cloud site successfully.

To create a Netlify account, follow these steps:

  1. Visit the Netlify website and sign up for a free account.

  2. Once your account is created, log in to Netlify.

  3. To create a new site, click on the "New site from Git" button or a similar option.

  4. Select the option "Import an existing project" when prompted.

  5. Choose the GitHub repository that contains your XM Cloud instance code. This establishes a CI/CD relationship between Netlify and GitHub.

  6. Netlify will automatically pull the latest code from the selected branch whenever you trigger a deployment in Netlify or via the command-line interface (CLI).

  7. Any changes made to the selected branch in GitHub will automatically trigger deploys in Netlify.

By following these steps, you can connect your XM Cloud instance to your existing Netlify account and leverage the CI/CD capabilities offered by Netlify.

Build Settings

The build settings in Netlify allow you to specify the commands that should be executed during the build process.

By configuring the build settings, you can provide instructions to Netlify on how to build your project. These instructions typically include commands that need to be executed, such as installing dependencies, compiling code, and generating the final build artifacts.


You can define the build commands in the Netlify UI or by configuring a build script in your project's repository. Netlify will execute these commands during the build process to prepare your site for deployment.

Customizing the build settings enables you to tailor the build process according to your project's requirements, ensuring that all necessary steps are performed correctly before deploying your site.

Environment variables

To proceed with the setup, it is necessary to create the required environment variables as mentioned earlier. However, please note that in a free account, setting the scopes or contexts for these variables may not be available. Nevertheless, you can still create the variables with their respective values.

The environment variables that need to be created are as follows:

  1. GRAPH_QL_ENDPOINT: Set this variable to the XM Cloud edge URL, typically in the format of "https://edge.sitecorecloud.io/api/graph/v1".

  2. JSS_APP_NAME: Specify the Site name in Sitecore.

  3. PUBLIC_URL: This variable should be assigned the generated URL for your site on Netlify. For instance, if your site's name is "sitename", the URL may look like "https://sitename.netlify.app/".

  4. SITECORE_API_KEY: Generate the access token using the provided "New-EdgeToken.ps1" script found in the repository mentioned earlier.


After setting up these environment variables, you will have a generated URL similar to " <sitename>.netlify.app", such as in the case of "https://sxastarter.netlify.app/".

Now that everything is set up, you can proceed to trigger a deploy by accessing the "Trigger deploy" option located in the deploy menu.


If the deployment is successful, you will see a deploy log similar to the following:


In case any issues arise during the deployment, the log will indicate a failure and provide a complete stacktrace of the error. This detailed error report can be quite helpful in troubleshooting and resolving any deployment-related issues.

Local Deployment

To deploy the site locally and push the build to your Netlify cloud account, follow these steps:

  1. Begin by installing the Netlify CLI. Open your command line interface and run the following command:

  2. Connect to your Netlify account by running either of the following commands:



    deploying-xm-cloud-static-site-deployment-with-netlify-cli-8 deploying-xm-cloud-static-site-deployment-with-netlify-cli-9

    During this process, you will be prompted with a series of questions about your Netlify account, such as the sites you want to use.

  3. Next, build the local folder and assets. This process requires the same settings as the build settings mentioned earlier on the Netlify website. You may be asked to specify the build command and the deployed folder. For example, if using Next.js, the build command could be:


    The deployed folder, in this case, might be `.next`.

  4. Finally, to build and deploy to your Netlify account, run either of the following commands:



    deploying-xm-cloud-static-site-deployment-with-netlify-cli-12 deploying-xm-cloud-static-site-deployment-with-netlify-cli-13 deploying-xm-cloud-static-site-deployment-with-netlify-cli-14

Upon successful deployment, you will be able to view your deployed website using the URL generated by Netlify.


I hope this walkthrough of creating local and cloud deploys in Netlify was helpful. As mentioned earlier, the process is similar to the experience with Vercel, and it is quite straightforward, thanks to the feature parity between the two platforms.