Hosting a static website with Skygear


#1

You can host a static website on Skygear, which is useful for simple web apps and static landing pages.

Hosting a static webpage on Skygear cloud can be done with easily with skycli.

Say we have this simple webpage built with HTML, CSS and JavaScript.

index.html
index.css
index.js

If you want a simple project to work with while you are following the tutorial, download one here: https://gist.github.com/tenwy/f7b69b8b8830c876c4e5d865c4fa17c9.

First, install skycli with npm.

npm install -g skycli

Then in your project directory, log into your Skygear account (the one you use to sign in skygear.io).

skycli login

Connect your project with your Skygear app. You should have set up an app at portal.skygear.io first.

skycli init

It will then walk you through the set up. Answer yes when you are asked if you want a static hosting directory.

You're about to initialze a Skygear project in this directory: /User/Your/File/Path. Confirm?
> yes

Select an app to associate with the directory:
> <select-one-from-the-list>

Do you want to create your static hosting directory (public)?
> yes

Select the project template:
> Empty

After skycli is initialised, you should see a public_html folder and a skygear.json file in your project directory.

Now, copy all your webpage related files into public_html folder, Skygear Static web hosting will only deploy files inside the public_html folder. Your project directory should like like this:

./your-project/skygear.json
./your-project/public_html
./your-project/public_html/index.html
./your-project/public_html/index.css
./your-project/public_html/index.js

Note: If you are deploying a compiled project, make sure you have placed the build inpublic_html folder.

Then, in your terminal, go to you project directory and run skycli deploy .

When you see “Build completed successfully”, you will be able to access your static webpage on https://{your-app-name}.skygeario.com/static/index.html.

Share with us your static webpage hosted on Skygear below :heart:


Skygear updates: Custom domain for static assets is now supported on Skygear.io 😎