Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App
Next Article:
How to Deploy a Basic Static HTML Website to Heroku?
Next article icon

How to Deploy a Basic Static HTML Website to Heroku?

Last Updated : 08 Jul, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Heroku is a simple and one-stop solution to host any website or server. This article revolves around how you can host your own Static HTML webpage on Heroku. To demonstrate this we are going to build a simple webpage and host it.

How-to-Deploy-a-Basic-Static-HTML-Website-to-Heroku

Prerequisites

  • Git
  • Heroku Account
  • Heroku CLI

Let's create a directory named "portfolio" for our project. We will connect this directory to our Heroku app so that whenever we update the local HTML file, changes reflect on the hosted website.

Step 1:

Create a directory with the name "portfolio" and change the working directory to it.

$ mkdir portfolio  $ cd portfolio  

Step 2:

Create your own static HTML website and name it “home.html” (We are going to create a simple file with just "My portfolio" as text)

$ echo "<h1> My Portfolio </h1>" > home.html   

Step 3:

Heroku by default does not allow you to deploy an application that does not have a backend. So we need to create a dummy backend or dynamic PHP file. We need to use a trick and tell Heroku that our website is a PHP application. To do this simply copy and paste the following commands in your terminal. composer.json has been included to provide support for PHP application on Heroku. If an app has no composer dependencies, we must include empty composer.json  to recognize the PHP application.

$ echo '<?php include_once("home.html"); ?>' > index.php  $ echo '{}' > composer.json  

Step 4:

Initialize the repository as a git repository.

$ git init  

Step 5:

Create your Heroku app using the new button on the top right side of Heroku dashboard. We are going to name this app as "your-app-name-123"

Step 6:

Login to your Heroku account using the Heroku CLI

$ heroku login  

Step 7:

Now that we have created our app, we just need to connect the local git repository to the Heroku app. To do this we add the remote of the Heroku app to the git repository. (Don't forget to replace "your-app-name-123" with your own app name)

$ heroku git:remote -a your-app-name-123  

Step 8:

Push the changes to your Heroku app.

$ git push heroku master  

Step 9:

Your app is now live on Heroku. To view your app, click on the link that appears at the end of the previous step, which looks like https://your-app-name-123.herokuapp.com/ . To commit and save all the changes to your home.html file, execute the following commands from your “portfolio" directory.

$ git add .   $ git commit -m "your commit message"   $ git push heroku master  

Next Article
How to Deploy a Basic Static HTML Website to Heroku?

G

gauravak007
Improve
Article Tags :
  • Web Technologies
  • HTML
  • Git
  • Heroku Cloud

Similar Reads

    How to Install Heroku and Deploy a Static Website on Ubuntu?
    Heroku is a cloud platform that provides a platform as a service(PAAS) to deploy either static or dynamic websites. Heroku is managed by Salesforce. Heroku allows CI/CD, code rollbacks, automatic deploys, Github integration, app metrics, and much more. Heroku allows building, running, and deploying
    3 min read
    How to deploy React app to Heroku?
    React is a very popular and widely used library for building User Interfaces. So if you are thinking about deploying your React app to the cloud platform, there are various choices for doing that such as AWS EC2 or Heroku. But for testing your React app, Heroku will be the best option as it is free
    3 min read
    How to Deploy website on Netlify
    You have your website ready and don't know how to reach the audience. Most of us coders create amazing websites using HTML, CSS, and JavaScript and just save them locally or on remote host services like GitHub and BitBucket. Now, what if you need non-programmers to view your work? This is why it bec
    2 min read
    How to Deploy a Golang WebApp to Heroku?
    Go, also known as "Golang," is gaining popularity among DevOps professionals in recent years. There are many tools written in Go, including Docker and Kubernetes, but they can also be used for web applications and APIs. While Golang can perform as fast as a compiled language, coding in it feels more
    5 min read
    How to Publish a Static Website on GitHub?
    Publishing a static website on GitHub is a great way to share your work with the world. GitHub Pages is a service offered by GitHub that allows you to host your static websites directly from a GitHub repository. In this article, we’ll walk you through the steps to publish your static website on GitH
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences