Hosting Your Site on GitHub

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
- Click on the "+" sign in the upper right corner and select "New repository."
- Name your repository (e.g.,
your-username.github.io
for a GitHub Pages site). - 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
-
Stage your changes:
git add .
-
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
- In your GitHub repository, go to "Settings."
- Scroll down to the "GitHub Pages" section.
- In the "Source" dropdown, select
main
or your preferred branch. - 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!