In my previous article "WordPress on Heroku", I explained the benefits of the Heroku platform and detailed how to setup a WordPress website for free. Since posting I have had a couple of questions asking if it's possible to host other static content on Heroku, for example a brochure site using HTML, CSS and JaveScript. The answer is yes and it's actually very easy to do!
I have seen a number of articles on the web that have detailed a fairly complicated process using Ruby, however there is a much simpler way using the unofficial support for PHP.
Simply create an "index.php" page with the following code:
Then, simply make your static web content (html, css, js and image files) link from "home.html" (you can also use php). For example, the image below shows my working directory, where you can see the "index.php" and "home.html" pages.
Once complete, you must creating a new Heroku app and upload the content. This can be done following the steps below:
3. Open Terminal (Applications > Terminal).
4. Login to Heroku and accept the certificate (if prompted):
5. Navigate to the directory that contains your static web content.
6. Run the following Git commands to create a repository and commit the initial push:
git add .
git commit -m "Initial Push"
7. Create a Heroku app (which will auto-generate a URL) and push the code:
git push heroku master
8. Run the app:
That's it! Your default browser should now open and load the page "home.html". Enjoy!