It enables local development, content management, and theme customization while providing a straightforward way to preview changes before deploying them to a live environment.
This guide will walk you through how to preview from HubSpot CLI, including installation, setup, and running preview commands.
Before you start, ensure you have the following:
Node.js installed (Latest LTS version recommended)
NPM (Node Package Manager) installed
A HubSpot account with CMS Hub access
HubSpot CLI installed
How to Preview from HubSpot CLI Commands in 7 Easy Steps
1) Install HubSpot CLI via NPM
The first step is to install the HubSpot CLI using NPM. If you haven’t installed it yet, run the following command:
npm install -g @hubspot/cli
This command installs the HubSpot CLI globally, making it accessible from any directory in your system.
To verify the installation, run:
hs --version
If installed correctly, the terminal will return the installed version of the HubSpot CLI.
2) Authenticate with HubSpot
After installing the CLI, you need to authenticate it with your HubSpot account.
Run the following command to connect your CLI to HubSpot:
hs auth
This will open a browser window prompting you to log in to your HubSpot account.
Once authenticated, the CLI will be linked to your HubSpot environment.
To confirm that your authentication is successful, use:
hs accounts list
This command will display all connected HubSpot accounts.
3) Setup a Local Development Environment
To develop and preview themes, you need to set up a local development environment by creating a new HubSpot CMS project or using an existing one.
To create a new project, use:
hs create website-theme my-custom-theme
Then, navigate into the theme folder:
cd my-custom-theme
For existing themes, navigate to the respective theme directory where your HubSpot files are stored.
4) Connect to HubSpot CMS
If you haven’t already, connect your local project to your HubSpot account:
hs init
This command will ask for your HubSpot account, select the correct account, and complete the setup.
You can also manually add your HubSpot portal ID to hubspot.config.yml file within your project directory.
I am a certified HubSpot Consultant, Full Stack Developer, and
Integration Specialist with over 15 years of experience successfully transforming
business-critical digital ecosystems. My expertise spans the entire software lifecycle,
ranging from high-performance web application development to managing large-scale
migrations, enterprise-grade CRM integrations, and secure compliance-driven solutions.