Is it possible to upload a simple html and javascript file structure to heroku?
A simple way is to masquerade the HTML app as a PHP App. Heroku properly identifies PHP apps.
- Rename your index.html file to home.html.
-
Create an index.php file and include your entry html file. If your HTML entry file is named home.html as recommended, your index.php should look like:
<?php include_once("home.html"); ?>
-
In your command line on the machine you are pushing from, type:
git add .
git commit -m 'your commit message'
git push heroku master
Heroku should properly detect your app now as a php app:
-----> PHP app detected
-----> Bundling Apache version 2.2.22
-----> Bundling PHP version 5.3.10
-----> Discovering process types
Procfile declares types -> (none)
Default types for PHP -> web
-----> Compiled slug size: 9.9MB
-----> Launching... done, v3
...
Mad Thanks to lemiffe for his blog post: http://www.lemiffe.com/how-to-deploy-a-static-page-to-heroku-the-easy-way/
Here is a more elegant method: Just add a file called package.json
which tells Heroku to use harp as your server:
{
"name": "my-static-site",
"version": "1.0.0",
"description": "This will load any static html site",
"scripts": {
"start": "harp server --port $PORT"
},
"dependencies": {
"harp": "*"
}
}
and then deploy to Heroku. Done!
Further information: https://harpjs.com/docs/deployment/heroku
You can use rack to do this:
https://devcenter.heroku.com/articles/static-sites-on-heroku
or you can use something like Octopress/Jekyll who uses sinatra.
But you need a minimum stack to serve html static content
Here is what worked for me:
cd myProject
git init
heroku create myApp
heroku git:remote -a myApp
If the entry point is main.html
, create index.php
with this single line of content:
<?php include_once("main.html"); ?>
and then perform the following steps:
echo '{}' > composer.json
git add .
git commit -am "first commit"
git push heroku master
Go to http://myApp.herokuapp.com/ and your app should be online now.
There's a much easier way to do it just in case anyone finds the other answers hard to follow.
Say you have your static website with the root at index.html
. Now you want to deploy it to Heroku, how?
# initialise a git repo
git init
# add the files
git add -A
# commit the files
git commit -m "init commit"
# Now add two files at the root, composer.json and index.php
touch composer.json
touch index.php
# add this line to index.php, making a PHP app that simply displays index.html
<?php include_once("index.html"); ?>
# add an empty object to composer.json
{}
Now simply run git push heroku master
and you're done!