Siteglide CLI is a tool that enables you to work on your project from your local editor and has similar behaviours to that of using FTP, in that you can sync up and pull down changes from your website. You will be required to use some terminal commands to use this feature.

Dependencies

The CLI is distributed via Node Package Manager (NPM) and so you will need NodeJS installed on your machine. The easiest way to get this is to visit https://nodejs.org/ and download the LTS version as this has better support.

Siteglide CLI requires a minimum of NodeJS version 10

Installing & Updating

You can use the following to install Siteglide CLI.

npm i -g @siteglide/siteglide-cli 

When an update is released for the CLI, you can use the same command as above to install the updated version. Please note that the flags for commands below are not available on all versions of the CLI, updating to the latest version will allow you to use all of them.

Installing on Windows

The following video will give you a complete walkthrough guide for setting up Siteglide CLI on a Windows machine. Feel free to skip ahead to the parts you find the most useful.

Installing on Mac

The following video will give you a complete walkthrough guide for setting up Siteglide CLI on a Mac. Feel free to skip ahead to the parts you find the most useful.

The steps I follow in the video can be found here. If you are using zsh as your shell then the commands here will have to be run against the ~/.zshrc file, not ~/.profile. ZSH is the default for Macs since macOS Catalina, to find out which shell you are using you can run echo ${SHELL} in terminal. If the ~/.profile or ~/.zshrc files do not already exist then you may need to create them first before running the export PATH command

Commands

These commands should be run from within the project folder.  Commands follow the format of siteglide-cli <command> <env> <flags> , so for example if you would like to sync to your production environment with direct asset upload you would run:
siteglide-cli sync production -d  

Add

The first time you use the CLI with a project on your device, you will need to create an environment. This is essentially a config file that authorises your connection.

siteglide-cli add <env> --email me@mydomain.com --url https://my_great_site.com

You must use the email of your Siteglide partner account to replace me@mydomain.com and the development domain of the website you are connecting with to replace https://my_great_site.com

After your site goes live, you will only be able to add the development domain to an environment, not your main user-facing domain.

Replace <env> with a chosen name for the environment, for example production. On larger projects you may have more than one environment to allow you to interact with both staging and production websites.

Sync

siteglide-cli sync <env>

This command will setup a watcher that will automatically sync file saves and deletions when that action happens on your machine. To stop the sync running, enter use the shortcut control + c in your terminal.

Flags:
-d : Direct asset upload to AWS S3 CDN with increased file size limits of 5GB per file.

-l: Turns on the live reload server. This enables automatic browser reloading of a page when a file is saved in your IDE.

Logs

siteglide-cli logs <env> 

This command will output the last 20 logs and then a live list of logs from your site. Logs are written by using the log liquid code, for example: {% log 'Hello World!' -%} . To stop the logs running, enter use the shortcut control + c in your terminal

Flags:
-f : Filter log types
-q : Quiet mode

Version

siteglide-cli -v

Check the current version of Siteglide CLI you are running. See the Siteglide CLI changelog to find the latest version number. If you need to update, see the "Installing & Updating" command section above.

Help

siteglide-cli help

Generates a list of valid Siteglide CLI commands available to you.

GraphQL

Deprecated - Please see the GUI command below

GUI
siteglide-cli gui <env>

This command will open up the GraphiQL and Liquid Evaluator editors locally. This will let you run Graph queries and mutations to test them out before creating them within your site. Also good for quickly getting data out of the database to check.

The Liquid evaluator tool lets you quickly test Liquid from the CLI, without having to create and save a page in Siteglide Admin.

To stop the GUI command running, enter use the shortcut control + c in your terminal

Flags:
-o: Automatically open GraphiQL in default browser

Pull

siteglide-cli pull <env> 

This will pull down all files from the site in to a folder named marketplace_builder within your current directory. During this process it will also overwrite any local versions of files if they already exist. If you have made any changes locally that you have not synced they WILL be overwritten. 

Flags:

-i: Ignore assets such as CSS and JS as part of the pull.

Note: Assets such as images and videos are not downloaded as part of CLI Pull

Init

siteglide-cli init 

This will create a blank folder structure within the folder you run the command, which includes all folders that are automatically created for you when making a new website on Siteglide. If these folders already exist, you will receive an error and so it will not overwrite existing files.

Deploy

siteglide-cli deploy <env> 

If you have made a lot of changes in your codebase, then you can use deploy to re-send all files to your site at once.  Deploy is a single command that will create a .zip  file of your site and then upload that to your website.

Flags:

-w : With assets, also deploys your sites assets folder, supports total assets of up to 5GB.

Export

siteglide-cli export <env> 

Export is very similar to Pull, but it will also grab all data.  This command will first grab all data from the site and export it into a data.json  file, then it will run a pull to grab your code base.

Flags:
-w : With assets, also download asset files from your instance such as images and PDFs.

--csv: Export the data files as CSV instead of JSON. Please note that these CSV's are currently not compatible with the ones that are exported/imported from Siteglide Admin

-a: Only export assets and not the sites codebase. This by default will only export code related assets (CSS/JS etc) within the /assets folder. It can be mixed with -w above to export all assets

Migrate

siteglide-cli migrate <env> --url <existing url>

Download and migrate an existing site to Siteglide using our site import tool. This tool will scrape the existing site, download all of the publicly accessible pages and assets, compress CSS/JS/images. Optionally with the auto-deploy flag it will then deploy as a static site to Siteglide.

Note: If you are using a Mac, running migrate in your “home” folder may fail. Please move into a different folder in terminal and then try again.

Flags:

--url: Existing sites URL, usually the homepage. This flag is mandatory

-n: No Optimization, skips the CSS/JS and Image optimization

-a: Automatically deploy the site after it has finished migrating

Changelog

To see the latest changes to the CLI, we have our changelog here

Did this answer your question?