LinuxCommandLibrary

surge

Serve static web pages using local files

TLDR

Upload a new site to surge.sh

$ surge [path/to/my_project]
copy

Deploy site to custom domain (note that the DNS records must point to the surge.sh subdomain)
$ surge [path/to/my_project] [my_custom_domain.com]
copy

List your surge projects
$ surge list
copy

Remove a project
$ surge teardown [my_custom_domain.com]
copy

SYNOPSIS

surge [options] [project_directory] [custom_domain]

Common usage examples:
surge
surge ./my-awesome-site
surge --domain example.com
surge ./dist example.com

PARAMETERS

--project <path>, -p <path>
    Specifies the local directory containing the static files to be published. Defaults to the current working directory if not specified.

--domain <domain>, -d <domain>
    Sets a custom domain for the published project. If omitted, Surge provides a unique auto-generated URL.

--add <alias>
    Adds an alias (another custom domain) to an existing project.

--list
    Displays a list of all projects deployed by the currently logged-in user account.

--whoami
    Shows the email address of the currently logged-in Surge user.

--login
    Prompts for email and password to log into your Surge account or create a new one.

--logout
    Logs out the current user from the Surge CLI.

--create
    Initiates the process to create a new Surge user account.

--force
    Forces a redeployment, overwriting existing files even if they appear unchanged.

--silent
    Suppresses most of the CLI output during the deployment process.

--config
    Allows configuration of Surge CLI settings, such as default project path or domain.

--help, -h
    Displays the help message with available commands and options.

--version, -v
    Shows the current version of the Surge CLI tool.

DESCRIPTION

The surge command, provided by the surge.sh Node.js CLI tool, is a popular utility for deploying static websites and front-end projects to a global Content Delivery Network (CDN) with minimal effort. It simplifies the process of publishing HTML, CSS, JavaScript, and image assets directly from your terminal. Users can deploy projects in seconds, automatically assign a unique Surge URL, and optionally configure custom domains and SSL certificates. Surge is particularly favored by front-end developers, designers, and educators for its simplicity and speed in showcasing web projects and single-page applications without requiring complex server setup. It abstracts away server configuration, making it accessible for quick prototyping and sharing.

CAVEATS

The surge command is not a built-in Linux utility. It requires Node.js and npm (Node Package Manager) to be installed on your system first, as it is distributed as an npm package. It is designed exclusively for publishing static web content; it cannot host server-side applications or databases. While Surge offers a free tier, certain advanced features like custom SSL for some domains or increased bandwidth may require paid plans.

INSTALLATION INSTRUCTIONS

To use the surge command, you first need to install Node.js and its package manager npm (Node Package Manager). Once npm is set up, you can install the Surge CLI globally using the following command in your terminal:

npm install -g surge

TYPICAL WORKFLOW

A common workflow for deploying a static site with Surge involves:
1. Navigating to your project directory in the terminal: cd my-static-project
2. Running the surge command: surge
3. If it's your first time, you'll be prompted to log in or create an account.
4. Surge will then suggest a project path (usually current directory) and a default domain. You can accept these or provide your own.
5. Once confirmed, Surge uploads your files and provides the live URL to your deployed site.

HISTORY

The surge.sh service and its corresponding CLI tool were launched in 2014 by Surge, Inc. It quickly gained popularity for its straightforward approach to static site deployment, providing a much-needed simple solution for front-end developers. Its ease of use and 'just deploy' philosophy made it a go-to tool for prototyping and sharing web projects. In 2021, Surge was acquired by Netlify, a leading platform for modern web development, which continued to maintain and support the Surge service.

SEE ALSO

npm(1), netlify(1), vercel(1)

Copied to clipboard