Static Website Hosting with surge.sh

Photo by Igor Miske on Unsplash

Static Website Hosting with surge.sh

Aug 25, 2022·

2 min read

This article will be of some help to you if you pondered over ways in which you could quickly test out the static website you are building, not just limiting it to your localhost. While there are many other free hosting options for you to consider, this article covers about surge.sh

Pre-requisite to Install Surge:

Validate your Nodejs and npm versions

node -v
npm -v

Simple command to install Surge

npm install --global surge

You'll get a message similar to as shown in the below image on successful surge package install:

image.png (you see updated in the message because the package already exists in my system)

Steps to start host your project on surge

  • Go to the directory in which you have your project
cd my-surge-project
  • Contents of your project directory should include index.html and styles.css ( if you are not using custom stylesheet link )

image.png

  • Run Surge from your project directory
surge

You'll be asked to provide your email address for registering on surge.sh, once you provide details, you'll be asked to confirm project path and then custom domain name. You'll get a success like below:

Success! - Published to nauseating-chairs.surge.sh
  • If you'd like to retain the domain you want to publish you future changes to and not want to enter it each time there is a change, you can store the domain name in the CNAME file
echo "nauseating-chairs.surge.sh" > CNAME

That's how simple it is to use surge! Let me know if you happen to build any of your projects on surge.

A simple implementation using surge is available here - surge-hosting-demo Thank you :)