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

前端 未结 10 1457
逝去的感伤
逝去的感伤 2020-12-04 06:25

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?

相关标签:
10条回答
  • 2020-12-04 06:49

    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.

    0 讨论(0)
  • 2020-12-04 06:51

    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/

    0 讨论(0)
  • 2020-12-04 06:53

    2020 Update:

    If you get a blank page with the PHP answer mentioned here, try this - If your homepage is at index.html :

    echo '<?php header( 'Location: /index.html' ) ;  ?>' > index.php
    echo '{}' > composer.json
    

    Creating a Git repo and committing after adding files :

    git init
    git add .
    git commit -m "My site ready for deployment."
    

    Heroku deployment -

    heroku login
    heroku apps:create my-static-site-example
    git push heroku master
    
    0 讨论(0)
  • 2020-12-04 06:54

    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

    0 讨论(0)
  • 2020-12-04 06:57

    Follow this steps

    Step 1

    Type touch composer.json index.php index.html

    Step 2 in the index.php type:

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

    and in the composer.json type {}

    Step 3

    git add .
    
    git commit -m "[your message]"
    
    git push ['yourrepo'] ['yourbranch']
    
    0 讨论(0)
  • 2020-12-04 06:58

    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 like so - 
    touch composer.json
    touch index.php
    
    # Then add this line to index.php, making a PHP app and just asking it to display index.html - 
    <?php include_once("index.html"); ?>
    
    # Now open composer.json and add an empty object - 
    {}
    

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

    0 讨论(0)
提交回复
热议问题