how to set up free github hosted website

Set Up Free GitHub Hosted Website

By Robert Clark
AD

Did you know you can create a personal website for free using GitHub Pages? This guide will walk you through the process of setting up and hosting your website directly from your GitHub account. Let's get started!

Setting up a free GitHub-hosted website is an excellent way to create an online presence, showcase your projects, or even launch a blog. It's also a fantastic opportunity to familiarize yourself with GitHub, version control, and static website development.

Understanding GitHub Pages

Before we dive in, let's understand what GitHub Pages is. GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, and renders them into a website.

AD
How to Host a Website for Free Using GitHub Pages
How to Host a Website for Free Using GitHub Pages
How to Get Started With GitHub in 2026 and Build Real Projects Fast
How to Get Started With GitHub in 2026 and Build Real Projects Fast
How to have a Free Website on GitHub | موقع الإلكتروني مجاني
How to have a Free Website on GitHub | موقع الإلكتروني مجاني

A GitHub Pages site is served from its own dedicated URL (e.g., username.github.io). It uses the GitHub version control system to manage updates, making it easy to collaborate and host your website alongside your other projects.

Prerequisites

To set up your free GitHub-hosted website, ensure you have the following:

How To Create A Free Website - with Free Domain & Hosting
How To Create A Free Website - with Free Domain & Hosting
How to Make a Website From Scratch With Domain and Hosting
How to Make a Website From Scratch With Domain and Hosting

Creating a Repository for GitHub Pages

First, you'll need to create a new repository with a specific naming convention. GitHub Pages uses the name of your repository (without the .git extension) to create the URL where your site is served.

To create your GitHub Pages repository:

AD
  1. Log in to your GitHub account (https://github.com/login)
  2. Click the '+' icon in the upper right corner and select 'New repository'
  3. Name your repository using the format: your_username.github.io (replace 'your_username' with your actual GitHub username)
  4. Leave the repository description and other options as their defaults, then click 'Create repository'

Setting Up Your Website

Now that you have your repository, you can start building your website. For this example, we'll create a simple HTML site with a single page.

A basic HTML file (usually named 'index.html') should contain the following structure:

```html Your Website Title

Welcome to your free GitHub-hosted website!

Add content here...

AD
```

Creating Your Website Content

Create a folder on your local machine for your website files. Inside this folder, create an 'index.html' file and add your website content as shown above.

You can also create separate folders for your CSS and JavaScript files. For example:

``` my-website/ |-- index.html |-- css/ | |-- styles.css |-- js/ | |-- script.js ```

Uploading Your Website to GitHub

Now that you've created your content locally, it's time to push it to your GitHub repository.

AD
  1. Open your terminal or command prompt and navigate to the folder containing your website files.
  2. Initialize a new Git repository: git init
  3. Add your files to the repository: git add .
  4. Commit your changes: git commit -m "Initial commit"
  5. Connect your local repository to your remote GitHub repository: git remote add origin https://github.com/your_username/your_username.github.io.git
  6. Push your committed changes to GitHub: git push -u origin main

Remember to replace 'your_username' with your actual GitHub username.

activating GitHub Pages

Now that your website files are in your repository, you need to tell GitHub to render them as a website. This is done through the GitHub Pages settings.

Here's how to activate GitHub Pages:

  1. Navigate to your repository on GitHub
  2. Click the 'Settings' tab at the top of the repository
  3. Scroll down to the 'Pages' section
  4. Under 'Source', select 'main' (or the branch you pushed your website files to)
  5. Click 'Save'

It may take a few minutes for GitHub to process and publish your website. Once complete, you'll see your live website URL under 'Your site is published at' in the 'Pages' section.

Customizing Your GitHub Pages URL

By default, your GitHub Pages URL will be https://your_username.github.io. If you want to use a custom domain, follow GitHub's guide on advanced GitHub Pages settings and custom domains (https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site).

The journey doesn't end here! Now that your website is live, focus on making it awesome. Explore themes, plugins, and other customization options to truly make it your own. Happy coding!

AD