Home » Javascript » Is it possible to upload a simple html and javascript file structure to heroku?

Is it possible to upload a simple html and javascript file structure to heroku?

Posted by: admin December 11, 2017 Leave a comment

Questions:

I’m trying to deploy an open source project of mine to heroku, it is by necessity very simple with just static html and javascript. But do they not support static sites? I’d rather not make it a Sinatra project if I don’t plan on ever using anything but html and javascript.

~/sites/d4-site $ heroku create --stack cedar
Creating quiet-ice-4769... done, stack is cedar
http://quiet-ice-4769.herokuapp.com/ | [email protected]:quiet-ice-4769.git
Git remote heroku added


~/sites/d4-site $ git remote -v
heroku  [email protected]:quiet-ice-4769.git (fetch)
heroku  [email protected]:quiet-ice-4769.git (push)


~/sites/d4-site $ git push heroku master
Counting objects: 53, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (53/53), 206.08 KiB, done.
Total 53 (delta 4), reused 0 (delta 0)

-----> Heroku receiving push
-----> Removing .DS_Store files
 !     Heroku push rejected, no Cedar-supported app detected
Answers:

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

Questions:
Answers:

A simple way is to masquerade the HTML app as a PHP App.
Heroku properly identifies PHP apps.

  1. Rename your index.html file to home.html.
  2. 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"); ?>

  3. 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/

Questions:
Answers:

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

Questions:
Answers:

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.

Questions:
Answers:

I know this might be a little old but I ended up using Vienna Gemw to deploy this, basically its a small Rack application that will let you serve everything in your public folder (css, images, js, html) with just a couple of lines of Ruby:

require 'vienna'
run Vienna

Also, for deploying this on heroku you need to create a Gemfile:

source 'https://rubygems.org'
gem 'rack'
gem 'vienna'

Then run bundle install, in case you don’t have the bundle gem installed just run on your terminal:

sudo gem install bundle

And thats pretty much of it, you can have more information on: http://kmikael.com/2013/05/28/creating-static-sites-in-ruby-with-rack/

Questions:
Answers:

There’s a very easy way to do it just in case anyone found the above answers hard to follow.

You have your static website with the root at index.html (say), now you want to diploy it to Heroku, how?

git init initialise a git repo

git add -A add the files

git commit -m "init commit" commit the files

Now add two files in the root, composer.json and index.php as,

touch composer.json

touch index.php

Now rename root html from index.html to home.html and then add this line to index.php,

<?php include_once("home.html"); ?>

then add {} to composer.json.

Now simply run git push heroku master and you’re done!

Questions:
Answers:

Hmmm… one reason that heroku is rejecting the app could be that it is trying to detect asset pipeline in rails 3.1.x apps i think.

Why not create your app on the default stack Bamboo by running just

heroku create

Then all your js and css can go into public folder in rails app with asset pipeline deactivated.

Questions:
Answers:

Well , whenever your Web-page’s contain HTML, CSS and JavaScript , so follow just 2 steps :

1) Make one file give name as index.html (keep evreything in it) ex:script,stylesheet & body.

2) Now, change these file, copy and paste these same file but change domain to index.php

Then deploy on a Heroku.

Hence this method will help you to deploy your Web-Pages

Leave a Reply

Your email address will not be published. Required fields are marked *