How to deploy static websites on Heroku
profile picture Written by Alan Dsilva
Heroku is a cloud platform as a service supporting several programming languages. One of the first cloud platforms, Heroku has been in development since June 2007, when it supported only the Ruby programming language, but now supports Java, Node.js, Scala, Clojure, Python, PHP, and Go.
heroku logo

You cannot deploy static websites like this one on Heroku as each app must run through a build process. The solution to this is that you trick Heroku into thinking that your static website is simply a PHP app.

Configuration steps

  1. You need to add two files to your project directory.
    • composer.json
    • index.php
    If you are running a linux machine this is pretty easy just type touch composer.json index.php
  2. Add the following line to index.php <?php include_once("index.html"); ?>
    This is assuming that you have a file named index.php in your project directory, else name it to your initial website file.
  3. Add the following line to composer.json - {} Heroku uses the file composer.json for dependency management in PHP projects. This files indicates that your project is written in php and thus is required
That's it your done.
Publish your changes to the branch that Heroku is watching for deployments and your build should now pass.
If you followed the inital steps while setting up your heroku account you should be fine.

Of course a better option to host static websites is Github Pages
github pages
If your site is site is static with just HTML, CSS, media files and some JS this is definitely the option to go with.
web developmentdeploymentweb host