- Start new app and
git init
it. - Go to Heroku and sign up there.
- On your apps page click on "Create a new app".
- Copy Heroku Git URL and add it to your app using
git remote add heroku your-git-url
. - Create sample index.html file.
- In order to serve html files Heroku needs to start some web server.
It can be nodejs, ruby or whatever language is supported by platform.
In case of this tutorial you will use built-in nodejs http package web server.
Sample implementation of web server, that can only serve static html files is app.js file.
It just try to read requested html file and if this file exists write its content to response.
Locally server can be started by
node app.js
command (you need nodejs installed). - Heroku doesn't know anything about your app.js file. In order to notify it, you need to create Procfile consisting of only line of code
web: node app.js
. - Now you need to create package.json file and the easiest way to do it is use
npm install
command. Just press enter few times - you don't to change anything. - Now commit all changes and push it to Heroku using
git push heroku master
. - Go to your app page on Heroku website and click on little rectangle with arrow near the name of your application. It will open your static application. That's it!