Hosting Static Content with surge.sh

· klm's blog


Original post is here: eklausmeier.goip.de

When you want totally hassle free hosting of static HTML then surge.sh is very attractive. It is easy to set-up and free of charge for most private users. It offers https out of the box from sectigo.com. It does not offer PHP, MySQL/MariaDB, CGI, Perl, etc. Just static HTML with CSS, JavaScript, images, etc. Your static content will be hosted on Your_Domain.surge.sh.

Steps to follow:

  1. Install surge: npm install surge
  2. cd to your directory with static content: Type surge

It cannot be easier. If you do not want to enter the domain name over and over again, you can store this chosen domain name in file CNAME and you won't be asked the next time:

1echo Your_Domain > CNAME

The surge command offers the following options.

 1$ surge --help
 2
 3  surge – single command web publishing. (v0.21.3)
 4
 5  Usage:
 6    surge <project> <domain>
 7
 8  Options:
 9    -a, --add           adds user to list of collaborators (email address)
10    -r, --remove        removes user from list of collaborators (email address)
11    -V, --version       show the version number
12    -h, --help          show this help message
13
14  Additional commands:
15    surge whoami        show who you are logged in as
16    surge logout        expire local token
17    surge login         only performs authentication step
18    surge list          list all domains you have access to
19    surge teardown      tear down a published project
20    surge plan          set account plan
21
22  Guides:
23    Getting started     surge.sh/help/getting-started-with-surge
24    Custom domains      surge.sh/help/adding-a-custom-domain
25    Additional help     surge.sh/help
26
27  When in doubt, run surge from within your project directory.

Your e-mail and encrypted password are stored in $HOME/.netrc.

The script surge will not honor symbolic links in your deployment directory. For example, an image directory will not get copied over to surge.sh.

My static site on surge.sh is here: eklausmeier.surge.sh.