How to Deploy a Basic Static HTML Website to Heroku?
Last Updated :
08 Jul, 2022
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.
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
Similar Reads
HTML Tutorial HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript
11 min read
HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML
14 min read
HTML Introduction HTML stands for Hyper Text Markup Language, which is the core language used to structure content on the web. It organizes text, images, links, and media using tags and elements that browsers can interpret. As of 2025, over 95% of websites rely on HTML alongside CSS and JavaScript, making it a fundam
6 min read
HTML Tags - A to Z List HTML Tags are fundamental elements used to structure and format content on web pages. They provide instructions to web browsers on how to render text, images, links, and other media.HTML tags are enclosed in angle brackets < > and usually come in pairs: an opening tag and a closing tag. The cl
15+ min read
30+ Web Development Projects with Source Code [2025] Web development is one of the most in-demand career paths in the IT industry, experiencing consistent growth of around 20â25% annually. Whether you're a student starting out or an experienced professional looking to switch or advance your career, it's essential to go beyond theory and demonstrate yo
4 min read
Frontend Developer Interview Questions and Answers Frontend development is an important part of web applications, and it is used to build dynamic and user-friendly web applications with an interactive user interface (UI). Many companies are hiring skilled Frontend developers with expertise in HTML, CSS, JavaScript, and modern frameworks and librarie
15+ min read
HTML DOCTYPE Declaration HTML DOCTYPE (Document Type Declaration) is an instruction that appears at the beginning of an HTML document, before the <html> tag.Its primary role is to tell the web browser which version of HTML the page is written in, ensuring that the browser renders the content correctly. It is not an HT
4 min read
HTML Forms HTML forms, defined using the <form> Tags are essential for collecting user input on web pages. They incorporate a variety of interactive controls such as text fields, numeric inputs, email fields, password fields, checkboxes, radio buttons, and submit buttons. Over 85% of websites rely on for
5 min read
HTML Tables HTML (HyperText Markup Language) is the standard markup language used to create and structure web pages. It defines the layout of a webpage using elements and tags, allowing for the display of text, images, links, and multimedia content. As the foundation of nearly all websites, HTML is used in over
10 min read
HTML Basics HTML (HyperText Markup Language) is the standard markup language used to create and structure web pages. It defines the layout of a webpage using elements and tags, allowing for the display of text, images, links, and multimedia content. As the foundation of nearly all websites, HTML is used in over
7 min read