Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Elian Van Cutsem
Elian Van Cutsem

Posted on • Originally published atelian.codes on

     

Using Surge.sh to quickly deploy a static site

Using Surge.sh to quickly deploy a static site

Deploying a static site can be really easy when usingNetlify,Vercel or another service. Most of them require to have a connection to aGithub (or similar) repository, although some of them also come with a CLI version.Surge.sh is a tool that makes it very easy to deploy a simple site via the command line without any hassle, this can be a useful tool to make a temporary link for a preview for a client or yourself.

Why use Surge over other services

Personally I like that Surge is just so easy. It's literally nothing more than a simple command. One thing that's also really likeable about Surge is that it doesn't require configuration. For instance, a 404 error code will just default to404.html, and any otheryourdomain.surge.sh/testpage will default totestpage.html. There is no GUI or any other way to really manage your sites. Don't forget that Surge only supports static sites, in other words, JAMStack sites (compiled to JavaScript, API's and Markup). So server-side-rendering is not an option.

Pricing

Surge has a free and paying plan, if you want to learn more about that, you can always take a look onthe official website. It comes down to two options.

The free plan includes basic SSL and unlimited publishing, which might be good enough to simple deploy preview versions for client or to use as tests for yourself. You can even use custom domains (likeyourdomain.surge.sh).

The paid plan costs $30/mo and includes HTTPS, unlimited domains, redirects, password protection per site and a lot of other features.

Installing Surge

Installing Surge is as easy as installing it as a global npm package:

npm install --global surge
Enter fullscreen modeExit fullscreen mode

Deploying a directory to Surge

So now that you have installed Surge, you can simply navigate into your directory with the site's code and assets and run thesurge command.

# Navigate to your (static) sitecd yoursite/# Deploy to Surgesurge
Enter fullscreen modeExit fullscreen mode

Surge will than (only the first time) ask you to log in or create your account, after which it asks you the subdomain of the site and immediately will start deploying. This only takes a little moment and once it's done, your website will be live in an instant.

Of course you need to keep in mind that Surge does nothing more than deploy a directory directly on the web, so there is no building or compiling involved. If you want (or need) to deploy a site withnode_modules, you could compile your website locally and just deploy the output build folder, or use an external CI/CD provider likeTravis orGithub Actions. To use CI/CD, you need to use an online repository of course.

Demo

Inthis repository I've added a new directory calleddemos, in which I'll provide future demo's of technologies and other programming / code related stuff. This time I used that repository to test Surge.sh and provide a simple look on how it works.

The demo of this article can be found onhttp://swapped-coffee.surge.sh. (It only contains anindex.html &404.html file)

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Core Astro Team | devs.gent meetup organizer | BeJS, React Brussels & React Paris household figure | public speaker | Podcast Host
  • Location
    Ghent, Belgium
  • Education
    Bachelors in ICT, specialisation in Web & Mobile development
  • Work
    Core Astro Team at The Astro Technology Company
  • Joined

More fromElian Van Cutsem

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp