Hosting Your Site on GitHub

Published on May 11, 2025 min read NaN views

Are you ready to share your web masterpiece with the world on GitHub? In this comprehensive guide, we'll walk through the process of uploading your site to GitHub, providing clear examples at every step.

Step 1: Create a GitHub Account

If you don't have a GitHub account, sign up for one at GitHub.com.

Step 2: Create a New Repository

  1. Click on the "+" sign in the upper right corner and select "New repository."
  2. Name your repository (e.g., your-username.github.io for a GitHub Pages site).
  3. Add a brief description, and initialize with a README if desired.

Step 3: Clone the Repository to Your Local Machine

Open a terminal and run the following command, replacing with your repository's URL:


git clone repository-url

Step 4: Add Your Site Files

Place all your site files (HTML, CSS, JavaScript, etc.) inside the cloned repository.


cd repository-folder

Step 5: Commit Changes

  1. Stage your changes:

    
    git add .
    
    
  2. Commit the changes:

    
    git commit -m "Initial commit"
    
    

Step 6: Push to GitHub

Push your changes to the GitHub repository:


git push origin main

Note: If you're using a different branch, replace main with the name of your branch.

Step 7: Enable GitHub Pages

  1. In your GitHub repository, go to "Settings."
  2. Scroll down to the "GitHub Pages" section.
  3. In the "Source" dropdown, select main or your preferred branch.
  4. Your site will be live at https://your-username.github.io/repository-name/.

Additional Tips:

  • Custom Domain:

    • If you have a custom domain, add it in the "Custom domain" section in GitHub Pages settings.
  • Updating Your Site:

    • Repeat Steps 4-6 whenever you want to update your site.

Congratulations! Your site is now live on GitHub Pages. Share your link and showcase your work with the world. Happy coding!