This is a quick tutorial explaining how to get a static website hosted on Heroku.
Why do this?
Heroku hosts apps on the internet, not static websites. To get it to run your static portfolio, personal blog, etc., you need to trick Heroku into thinking your website is a PHP app.
Basic Assumptions
- You want to deploy some straight-up HTML, CSS, JS, maybe a few images. Nothing fancy here.
- You are in the root directory of your site (i.e. the directory that contains all subdirectories and files for the site)
- The root directory contains a main HTML page, e.g. index.html
- A Heroku app and remote are set up and ready to go
- You can download the source code from here
- Clone the source code from git and extract your local machine.
![](https://i2.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/1.png?fit=1024%2C496&ssl=1)
Right-click and click on Git Bash
![](https://i0.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/2.png?fit=1024%2C512&ssl=1)
Follow the below Git commands as per the screenshot
Execute
$ git init $ git remote add origin https://github.com/kumaresankandasamy/webapplication_master.git $ git status $ git add .
![](http://13.233.230.40/wp-content/uploads/2020/07/3.png)
Execute
$ git commit -m "add webapplication master" $ git push origin master
![](http://13.233.230.40/wp-content/uploads/2020/07/6.png)
Next, Refresh your git repository web page.
![](https://i1.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/8.png?fit=1024%2C499&ssl=1)
Then, Login Heroku and click on create new app
![](https://i0.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/10.png?fit=1024%2C470&ssl=1)
Add a app name, region and click on create app
![](https://i2.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/11.png?fit=1024%2C492&ssl=1)
Then Click on Heroku Git CLI
![](https://i2.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/12.png?fit=1024%2C479&ssl=1)
open windows command prompt in the local root folder where you have cloned sourcecode and run the below commands.
Execute
heroku login
Press any key to open up the browser to login Heroku
![](https://i2.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/13.png?fit=1024%2C504&ssl=1)
Click on the login button and run the below commands on windows command prompt
![](https://i0.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/14.png?fit=1024%2C516&ssl=1)
Execute
git init git:remote -a nmasterapp git add . git commit -am "make it better application" git push heroku master
![](https://i2.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/15.png?fit=1024%2C425&ssl=1)
Build the package
![](http://13.233.230.40/wp-content/uploads/2020/07/16.png)
Successfully deployed the package
![](https://i2.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/17.png?fit=1024%2C506&ssl=1)
Run the URL in a browser ClickHere
![](https://i0.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/18.png?fit=1024%2C532&ssl=1)
Another way, you can deploy your application connect to GitHub
![](https://i0.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/19.png?fit=1024%2C513&ssl=1)
Search and connect to your git repository
![](https://i0.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/21.png?fit=1024%2C520&ssl=1)
To enable automatic deployment
![](https://i1.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/22.png?fit=1024%2C504&ssl=1)
Click on deploy branch, now your application successfully deployed.
![](https://i0.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/24.png?fit=1024%2C454&ssl=1)
You can see the application in a browser ClickHere
![](https://i2.wp.com/geeksnewslab.com/wp-content/uploads/2020/07/25.png?fit=1024%2C505&ssl=1)
Video Tutorial – Deploy in Heroku through Github and Heroku
Happy Learning !
Be First to Comment