Open In App

How to Host a Website on GitHub For Free?

Last Updated : 14 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

GitHub is not only a platform for version control and code management but also a great tool for hosting websites for free. Whether you want to host a personal blog, a project portfolio, or just showcase your work, GitHub Pages offers a simple way to publish a static website directly from a GitHub repository.

In this article, we'll discuss how to host a website on Github for free.

Host Website on Github For Free
How to Host a Website on GitHub For Free?

Steps for Hosting Website on GitHub

Here, we are going to discuss the step-by-step process of hosting a website on GitHub for free. So, you can also host your portfolio or your college project online with GitHub.

Step 1: Create a GitHub account

  • The first step is to create a GitHub account if you don't have one already. You can create an account for free on the GitHub website.
  • If you already have one then do github login to your account.
Screenshot-2025-04-14-183847
GitHub

Step 2: Create a new repository

  • Next, you need to create a new repository to host your website.
  • To create a new repository, click on the "Create repository" button on your left section after the new registration.
  • You can also do it by clicking on the "new" button on your GitHub Dashboard.
  • Give your repository a name that corresponds to your username. For example, if your website is called "username", name your repository "username.github.io".
Create New Repository
Create new repository

Give the description of the website you are creating and then click on "create repository" button.

Name the repository
Name the repository as your username.github.io

Step 3: Create an index.html file and a web.css file

  • To create a website, you need an HTML file that contains the content of your website.
  • You can create a new HTML file using a text editor like Visual Studio Code or Notepad.
  • Save the file as "index.html" in your local repository.

Or

Click on " creating new file" or "new file" to create a new file and name the created file.

Create New File
Create new file

Name the file with the ".html" extension so that you can add the HTML code for your website. Add the code for your website below in the edit section.

Add HTML code
Create index.html and add  the HTML code for your website

Add a description and "Commit changes" button so that your code gets added and saved on GitHub. 

Commit HTML code
commit the  HTML code

Add the CSS code for your website by doing the same process as above and then add a description and click on the "Commit changes" button.

Add Css code
Create index.html and add  the CSS code for your website
Commit css code
Commit the CSS code

Step 4: Enable GitHub Pages

  • After pushing your code to your repository, you need to enable GitHub Pages for your repository.
  • To do this, navigate to your repository on GitHub and click on the "Settings" tab.
  • Scroll down to the "Pages" section from the left section.
GitHub pages
Go to pages in the left section in the settings

Step 5: Visit your website

  • Once GitHub Pages are enabled for your repository, your website is now live! You can visit your website by navigating to https://your-username.github.io/ in your web browser.
  • It might take a few moments for the changes to propagate and for your website to be accessible.
Visit your hosted site
Final Hosted site
How to Host a Website on GitHub For Free?

Why Use GitHub for Website Hosting?

  • Free Hosting: GitHub Pages offers free web hosting with custom domains.
  • Ease of Use: It is easy to set up and requires minimal effort, especially for static websites.
  • Version Control: You can easily manage your website’s source code with GitHub’s version control system.
  • Integration with GitHub Projects: If you’re already using GitHub for version control, hosting your website is seamless.

Conclusion

Hosting your website on GitHub Pages is a great way to make your website accessible to the world for free. By following the steps above, you can easily host your website on GitHub Pages and share your content with the world. In summary, hosting your website on GitHub Pages involves creating a repository, setting up your local development environment, creating and customizing your website's files, committing and pushing your changes to GitHub, enabling GitHub Pages in the repository settings, and accessing your hosted website through the provided URL. Remember to regularly update and maintain your website by pushing changes to your repository.


Next Article
Article Tags :

Similar Reads