Blog Post

host website on github

A Step-By-Step Guide on How to Host a Website on Github

Finding a way to host your static website and personal projects can sometimes seem daunting, especially if you’re new to web development.
 
But, with the advent of modern platforms like GitHub, the process has become much more straightforward.
 
GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, runs the files through a build process, and publishes a website.
 
In this guide, we’ll walk you through the steps to host a website on GitHub, enabling you to showcase your projects, blogs, portfolios, and more to a global audience.

Tools to Setup Before Hosting Your Website on Github

Before we dive into the steps, make sure you have the following:
1. A GitHub account: If you don’t have one, sign up for a free account on GitHub.
2. A code editor. You can download Visual Studio Code or Sublime Text code editor.
3. Your website code: Your website’s HTML, CSS, and JavaScript files should be ready.

How to Host Your Website on Github

The following are easy steps to start with GitPages and make your website available online. Let’s get started:
 

Step 1: Create a New GitHub Repository

  • Log in to your GitHub account.
  • Click on the ‘+’ icon in the top right corner and select “New Repository”.

create new repository on github

  • Give your repository a name. It’s a good practice to name it something related to your website.

give repository a name

  • Choose the repository’s visibility. If you want to make your website public, choose “Public”. For a private website, choose “Private”.
  • Initialize the repository with a README. This will display descriptions about your website, and make things easier as you go along.
  • Click “Create Repository.”

Step 2: Upload Your Website Files

You can upload your website files in two ways:
  • Using the GitHub Desktop App: Install the GitHub Desktop app, select your repository, and drag your website files into the repository’s folder. Then, commit and push the changes.
  • Using the Command Line: If you’re comfortable with the command line, navigate to your website folder and use the following commands:

git init
git add .
git commit -m "Initial commit"
git remote add origin <repository URL>
git push -u origin master

Step 3: Set Up GitHub Pages

  • Go to your repository on GitHub.
  • Click on the “Settings” tab.
  • Scroll down to the “GitHub Pages” section.
  • Under “Source,” choose the branch where your website files are being stored (usually “main” or “master”).
  • Select the root folder as the directory.
  • Click “Save”.

Step 4: Access Your Website

  • After saving, scroll down to the “GitHub Pages” section.
  • You’ll find a link to your hosted website. It might look like: `https://yourusername.github.io/repositoryname/`.
  • Open this link in your web browser to see your website live!

Step 5: Make Updates

Whenever you want to update your website:
  • Edit your website files on your local machine.
  • Use the GitHub Desktop app or the command line to commit and push the changes to your GitHub repository.
  • Your website will automatically update on GitHub Pages within a few minutes.

Conclusion

Hosting a website on GitHub has become incredibly accessible, even for those with minimal technical background.
 
By following this step-by-step guide, you can showcase your web projects to the world without the complexities of traditional hosting solutions.
 
Note that: to host your dynamic web application that uses a backend programming language like PHP, Node JS, Django, Ruby etc, you need to buy a reliable web hosting service, and upload your web application to an online server.
 
So, go ahead and launch your website – the internet is waiting to see what you have to offer!
 
If you like this article, Kindly follow our Twitter page to receive more helpful tips about website hosting. Also, check out our amazing affordable and secure web and domain hosting services to help grow your business at a fast pace. Lastly, kindly share this article on all social media platforms.

Leave a Reply