Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
What is the CLI and Why use it?
Siteglide CLI (Command Line Interface) is a tool that enables you to work on your project from your local IDE or Code Editor; it has similar behaviours to FTP (File Transfer Protocol), in that you can sync up and pull down changes from your website.
Developers will be at home with the Siteglide CLI. It allows them to work faster than they can using the User Interface of the website. It also allows them to access the full suite of time-saving extensions and search tools in IDEs like VSCode and Atom.
But it's not just for Developers! Designers, SEO specialists and Agency Leaders may also find benefits to learning and using Siteglide CLI - allowing them to see an overview over their entire project and quickly find the files they're looking for.
Check the "File Structure" in each documentation topic, and this will help you find your way around the folders and files.
With CLI, we can validate code sent to the site. This is especially useful if you are syncing Liquid or GraphQL code where there are fewer 3rd party tools for linting. If there is a problem we can pick up automatically- the sync will fail and an error message will try to help you find the problem.
With Siteglide CLI we can keep track of the Code pushed to the Site from Admin and from local machines and make sure the Site always contains the most up to date pushes. It gives us scope to improve this functionality in the future.
Other CLI commands like siteglide-cli graphql and siteglide-cli logs
provide developers with advanced tools that would not be available with an FTP.
Siteglide Command Line Interface
Get started with our CLI
If unsure please read more about CLI first:
The Siteglide CLI can be installed from NPM using:
If you hit any issues please check our Troubleshooting guide:
Setup a local folder and use the site specific command to connect directly to your site (you can find this on the site details page in Portal - more info):
Need some help? Read our full Site Setup Guide:
You should now be ready to start work, you'll likely want to pull down the files from the server:
Check out our Reference article for a full list of useful Commands:
If you're using Flowbite/Tailwind please ensure you have Tailwind setup to compile CSS: Set Up Tailwind CSS with the recommended CLI method
In a Command Line, in any directory, type in:
If you already have siteglide-cli installed globally, this will tell you which version you have installed.
You can find out which is the latest version here:
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 and download the LTS version as this has better support.
Siteglide CLI requires a minimum of NodeJS version 10 but we recommend using the latest / LTS version
Open the download and follow the wizard with the default options to finish install.
You can use the following to install Siteglide CLI in any directory. The -g
flag instructs your machine to make this command available in any directory (globally)- so you only need to do this on your machine once.
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.
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.
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.
Read our in-depth guide:
Sometimes Siteglide support may ask you to run the CLI in "debug mode". This provides more output into your terminal so that we can use it to aid in supporting you. To do this, you need to prefix the command you are running with some extra information. This prefix differs slightly on macOS, Linux and Windows, for example if you were to want to sync to a site with debug mode on:
Note, for macOS and Linux, debugging will be turned on for that one command that you prefix. For Windows, debugging will be turned on for as long as Command Prompt or Powershell is open. Closing Command Prompt or Powershell and re-opening it will turn debug mode off.
We are using 99
as an example WebApp ID in this doc. Depending on the WebApp ID that you'd like to use, replace 99
with the correct ID. Keep in mind that if you already have WebApps in the site you are working on then then some WebApp IDs may already be reserved.
WebApps in Siteglide rely on 3 different files to work correctly.
JSON Structure - Used by Siteglide Admin and front-end to define structure of the WebApp with user-friendly names, and other UI metadata.
Schema - Used to define the database structure itself
Form Configuration - Used when submitting WebApp items front-end
There are 2 ways to create/edit a WebApp via CLI.
Safest - Create/Edit the JSON structure file (marketplace_builder/views/partials/tables/webapps/99.liquid
), and then in Siteglide Admin simply click 'Save' in the Table Builder view. This will generate a matching Form Configuration and Schema file.
Most flexible - Create/Edit each of the 3 files manually. However, this relies on you keeping all 3 files in sync.
This is used by Siteglide Admin to output WebApp field data with user-friendly names and other UI options (order, field type, etc.)
Location: marketplace_builder/views/partials/tables/webapps/99.liquid
Contents:
This is what defines the database table structure, and how data will be stored.
Location: marketplace_builder/custom_model_types/webapps/webapp_99.yml
Contents:
This is used when submitting a WebApp item front-end. This file was also previously used to output WebApp structure data in Siteglide Admin, but that is now the job of the JSON structure file.
Location: marketplace_builder/form_configurations/webapps/webapp_99.liquid
Contents:
After both the above files are synced you will then need to refresh Siteglide Admin and your WebApp will appear under WebApps in the sites left hand menu
If you need layouts for your WebApp, these will be saved to:
marketplace_builder/views/partials/layouts/webapps/webapp_99/detail/default.liquid
marketplace_builder/views/partials/layouts/webapps/webapp_99/list/default.liquid
Both files contain the following layout by default: <p>{{this['name']}}</p>
The main commands you'll need when using Siteglide CLI
You need CLI installed first, check out our Quickstart guide:
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 view the logs of your production environment in "quiet mode", you would run:
siteglide-cli logs production -q
Please note that some commands may fail if you run them in your users home directory. We recommend a folder structure such as siteglide/
and then give each project/site it's own folder.
Command flags such as <command>
<env>
and <flags>
should be replaced with the relevant data. For example, <env>
should be replaced with the chosen name for the environment such as production
.
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 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.
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:
-l
: Turns on the live reload server. This enables automatic browser reloading of a page when a file is saved in your IDE.
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: `
. To stop the logs running, enter use the shortcut
control + c` in your terminal
Flags: -f
: Filter log types -q
: Quiet mode
siteglide-cli -v
siteglide-cli help
Generates a list of valid Siteglide CLI commands available to you.
Deprecated - Please see the GUI command below
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
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.
-m
: Provide the name of a module to download. Note that this will only download that module and not the site as well. This will only download the public
folder within the module, if the module only contains a private
folder then nothing will be downloaded.
Note: Assets such as images and videos are not downloaded as part of CLI Pull
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.
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.
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
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. The migrate command will also convert any existing forms (using the <form>
tag) to a "form to email" in Siteglide. When filled in, this will email the user who triggered the CLI migration with an autoresponder. These forms can then optionally be updated at a later date within Siteglide Admin.
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
-m
: A number to set the level of recursion that the scraper will search through the site. For example setting -m 1
will only follow 1 link deep from the entry page
-i
: A string to send to the scraper that if found in the URL it will ignore downloading that page. For example if your blog posts are links such as site.com/post/post-name
and you wanted to ignore them, you could use the flag -i /post/
This flag can be used multiple time such as -i /blog -i /posts/
siteglide-cli list
Output a list of environments you have previously added and their relative URLs for the current folder.
siteglide-cli modules <env>
Provides a list of modules installed onto the instance. These names can then be used in the pull
command to download the contents of that module.
The steps followed in the video can be found . 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
Please see the document for all the relevant types.
The above are all the default fields that are needed, the last field is an example of a standard text field. Please see the document for all the relevant types.
Check the current version of Siteglide CLI you are running. See the to find the latest version number. If you need to update, see the "Installing & Updating" command section above.
Connect to a site via CLI
You need CLI installed first, check out our Quickstart guide:
Once you've installed the CLI you should be ready to learn how to set up a new project folder and connect it to a specific Siteglide Site. You'll need to follow these steps every time you want to use the CLI to work on a new site, so over time these will become very familiar.
Your project folder will contain all of your Site's files.
Use Finder on Mac, or Windows Explorer to create this new empty folder, and give it a similar name to your site so you can find it again. We recommend creating this folder inside a sensible organisation structure, for example you may have a single folder which contains all of your project folders, or you might organise by customer.
In order for a CLI tool's ability to deploy and pull code from a Site to be useful, we need to have a good place to look at and change that code.
While you are free to use any kind of terminal or any kind of Text Editor, we'll use VSCode for these steps- one major benefit is that its integrated terminal allows you to easily manage your project in one place. It also comes with lots of useful extensions.
If you do not already have a text editor installed, you can browse for one or install VSCode here: https://code.visualstudio.com/download
You can then open your project folder in the Text Editor:
If your IDE or Text Editor does not have an integrated terminal, you can open any terminal and change directory to your project folder.
The terminal will appear in its own panel, by default below the code. In VSCode this will automatically change directory to your project folder (if not, do this manually)!
If you need to run multiple commands at once, you will need two terminals. In VSCode you can "split" the terminal window if you want to run multiple commands at once and keep an eye on all of them.
Open up the Siteglide Portal and find your Site in the Sites option in the left-hand-side menu.
In the Users tab, make sure your user's email address is listed. If not, invite yourself (as an existing user) to the Site.
In the Details tab, near the bottom of the Site information, find the CLI Command and copy it.
Paste the command into your integrated terminal.
When prompted, enter the Siteglide Password associated with the email address in the command.
This won't work unless you follow step 5 first! If you forget your password, you can reset your password on the Siteglide Portal first.
This command creates what we call an envrionment. Think of it as a connection between a project and a Site. Sometimes you may maintain a staging Site and a live Site for the same project and you might create both a staging and a production environment.
You will need to remember the name of your environment in order to use any other Siteglide-CLI commands, but if you forget, there will be a .siteglide-config file in the root of your project folder which will list them:
You're now set up with Siteglide-CLI for this Site! The obvious first move would be to pull the existing Site's files down to the Site, using the following command in the terminal:
This will create your directory structure and populate it with your site's files and assets (images will not be pulled due to their size - see export command).
If you use Github for backing up your code, debugging and undoing mistakes, it's a good idea to initiate it and make your initial commit now.
You now know how to set up Siteglide CLI on a Site! You can follow these steps every time you want to work on a new Site.
Next, check the Reference for how to:
Deploy all your code to the site
Sync individual files to the site as you save them
And remember how to pull all the code down to your project folder