DEV Community

irishgeoff22
irishgeoff22

Posted on

github pages step by step

Certainly! Here's a step-by-step guide on how to set up GitHub Pages for a simple website:

1. Create a GitHub Repository:

  1. Go to GitHub and log in.
  2. Click the "+" sign in the upper right corner and select "New repository."
  3. Name your repository (e.g., my-website).
  4. Optionally, add a description.
  5. Choose the visibility (public or private).
  6. Initialize this repository with a README if you want.

2. Create Website Files:

  1. Create an index.html file in the root of your repository.
  2. Add some basic HTML content to index.html. For example:
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My Website</title> </head> <body> <h1>Hello, GitHub Pages!</h1> </body> </html> 
Enter fullscreen mode Exit fullscreen mode

3. Commit and Push:

  1. Open a terminal or command prompt.
  2. Navigate to your project directory.

    cd path/to/your/repository 
  3. Add and commit your changes.

    git add . git commit -m "Initial commit" 
  4. Push your changes to GitHub.

    git push origin main 

4. Enable GitHub Pages:

  1. Go to your GitHub repository on the web.
  2. Click on the "Settings" tab.
  3. Scroll down to the "GitHub Pages" section.
- In the "Source" dropdown, select `main` (or `master` depending on your default branch). - Click "Save." 
Enter fullscreen mode Exit fullscreen mode

5. Access Your Website:

After a few moments, GitHub will build and deploy your website. You can access it at:

https://yourusername.github.io/repositoryname 
Enter fullscreen mode Exit fullscreen mode

Replace yourusername with your GitHub username and repositoryname with the name of your repository.

6. Custom Domain (Optional):

If you have a custom domain:

  1. In the "GitHub Pages" section, add your custom domain.
  2. Configure your domain registrar to point to GitHub's IP addresses. GitHub provides instructions for this.

7. Update Your Website:

Whenever you make changes to your website:

  1. Commit and push the changes to your repository.
  2. GitHub Pages will automatically update your site.

That's it! You've successfully set up a basic website using GitHub Pages.

Additional information. To add Contact Form Github Pages

Top comments (0)