If you’re exited about static website but you’re still undecided whether to host it on Digital Ocean, AWS or Github Pages, then read this article. I’m hoping that you’ll like my quick guide on how to host a static site for free.
I have hosted sites on Github pages in the past. It’s convenient and fast enough, but I wanted to explore other solutions. I looked into hosting static sites on Dropbox, but I felt that there was too many restriction and it wouldn’t fit in my workflow.
Then I stumbled upon Surge.sh which I got exited about right away. Here’s how they describe it: > Simple, single-command web publishing. Publish HTML, CSS, and JS for free, without leaving the command line.
Why I love Surge?
- It couldn’t be easier to deploy a static site; once installed and configured simply run
- It has both a Grunt & Gulp plugin so it’s easy as a pie to integrate with your existing project
- You can use Git Hooks and deploy every time you push to Github or Bitbucket
- Deploying to your custom domain is free
- It’s blazing fast. This site takes 1.2s to load
So what’s missing?
Adding a free SSL Certificate
You can use basic SSL only if you don’t use your custom domain. But if you want to use with your domain, you don’t need to pay $13 / month. You can actually get it for free from CloudFlare.
Forcing HTTP to HTTPS
While I managed to get a free SSL from CloudFlare, I was still wondering how to force SSL. Fortunately, CloudFlare allows you to setup a 301 redirect to force HTTPS. Follow the few steps below:
- Login to your CloudFlare account
- Select your domain name
- Click “Page Rules” in the top navigation
- Add new rule where URL pattern is the URL of your website (for instance http://example.com)
- Toggle Always use https & Hit Add rule
Please leave some feedback in the comments.