Arul's Blog

Hosting a static website in a minute for free with

Tue 25 August 2020 By Arulmurugan Rajaraman comments

Deploying a static website involves more number of steps and will always take time. Because we have to create an account with a hosting provider, register your domain, install a FTP client and then upload your HTML files to the server. Phew! How many steps!!!

This is what I thought before trying Now hosting a static website couldn't be more easier than this. Here are the steps to do that. lets you deploy a static website from command line in a minute. You can deploy your site for free and they are offering a subdomain in You can also use your own domain with your website.

Step 1 - Install surge

Install surge using the following command

sudo npm install surge

Step 2 - Deploy your static site

You can deploy your site either to a subdomain or to your own domain.

Step 2.1 - Deploy to subdomain

Open terminal and change directory to your site's root folder. Then you can deploy your site using the command surge. If this is your first time you will be asked to enter your email and choose a password.

Your site will be uploaded to server depending on your internet speed and you will be given the site URL at the end of the upload. You can edit the URL if you want before the final step. You will be given a * subdomain.

Step 2.2 - Deploy to your domain

You can use your already existing domain or you can create a domain for free at Freenom. Open terminal and change directory to your site's root folder. Then you can deploy your site to your domain using the command

surge ./

Then go to your domain's DNS editor and create the following DNS records:

@   - TXT   -
www - CNAME -

Step 3 - Setup CNAME file

Specify your domain in a CNAME file with the following command for future deployments

echo > CNAME


echo > CNAME

You can deploy this change or any other changes in the future with the command surge. Your site is now deployed for free at or depending on the method you chose.

Run surge -h or surge --help to get the information given below:

Surge  Single-command web publishing. (v0.12.0)

  surge [options]

  -p, --project       path to projects asset directory (./)
  -d, --domain        domain of your project (<random>
  -e, --endpoint      domain of API server (
  -a, --add           adds user to list of collaborators (email address)
  -r, --remove        removes user from list of collaborators (email address)
  -V, --version       show the version number
  -h, --help          show this help message

Shorthand usage:
  surge [project path] [domain]

Additional commands:
  surge whoami        show who you are logged in as
  surge logout        expire local token
  surge login         only performs authentication step
  surge list          list all domains you have access to
  surge teardown      tear down a published project

  Getting started
  Custom domains
  Additional help

When in doubt, run surge from within you project directory.

You can see a detailed demo of in the YouTube video given above. Feel free to post your comments.

comments powered by Disqus