top of page
Anwaarul Haque

Build a Website with HTML, CSS, and GitHub Pages


'Build a Website with HTML, CSS, and GitHub Pages,' featuring icons for HTML, CSS, and GitHub Pages, along with a simple website layout


Creating your own website is easier than ever, thanks to the combination of HTML, CSS, and GitHub Pages. Whether you're a beginner looking to showcase your portfolio or a professional wanting a personal site, this guide will walk you through the steps to build a simple yet elegant website and host it for free using GitHub Pages.


Step 1: Set Up Your Development Environment

Before diving into the code, ensure you have the necessary tools:

  1. A Text Editor: You can use any text editor, but Visual Studio Code (VS Code) is highly recommended due to its robust features and extensions.

  2. Git: This is essential for version control and deploying your website on GitHub Pages. Download and install Git from git-scm.com.

  3. GitHub Account: Sign up for a free GitHub account if you don't already have one.


Step 2: Create Your Project Directory


Start by creating a directory on your computer where you will store your project files.

mkdir my-website 
cd my-website

Step 3: Create Your HTML File

Inside your project directory, create an index.html file. This will be the main page of your website.


<!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>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <header>
        <h1>Welcome to My Formclick</h1>
    </header>
    <main>
        <section>
            <h2>About Me</h2>
            <p>Hello! I'm [Your Name], a web developer.</p>
        </section>
    </main>
    <footer>
        <p>&copy; 2024 My Website</p>
    </footer>
</body>
</html>

Step 4: Style Your Website with CSS Create a styles.css file in the same directory to add some basic styling to your HTML content.


body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
}

header {
    background: #333;
    color: #fff;
    padding: 10px 0;
    text-align: center;
}

main {
    padding: 20px;
}

h1, h2 {
    color: #333;
}

footer {
    background: #333;
    color: #fff;
    text-align: center;
    padding: 10px 0;
    position: absolute;
    bottom: 0;
    width: 100%;
}

Step 5: Initialize a Git Repository

Initialize a Git repository in your project directory and commit your files.


git init
git add .
git commit -m "Initial commit"

Step 6: Create a GitHub Repository

  1. Go to GitHub and create a new repository. Name it my-website (or any other name you prefer).

  2. Do not initialize it with a README, .gitignore, or license, as we already have our local repository set up.


Step 7: Push Your Code to GitHub

Link your local repository to the GitHub repository and push your code.


git remote add origin https://github.com/your-username/my-website.git
git branch -M main
git push -u origin main

Step 8: Enable GitHub Pages


Go to your repository on GitHub.

  1. Click on the "Settings" tab.

  2. Scroll down to the "GitHub Pages" section.

  3. Under "Source", select the branch main (or master if that's what you named it).

  4. Click "Save".


After a few minutes, your website will be live at https://your-username.github.io/my-website/.


Step 9: Customize and Expand Your Website


Now that your website is live, you can continue to customize and expand it:

  • Add More Pages: Create additional HTML files for different sections of your website (e.g., about.html, contact.html).

  • Enhance Your CSS: Use CSS frameworks like Bootstrap or Tailwind CSS for more sophisticated designs.

  • JavaScript: Add interactivity with JavaScript.


Conclusion

Building a website with HTML, CSS, and GitHub Pages is a great way to learn the basics of web development and deploy a site for free. This simple guide has provided you with the foundational steps, but the possibilities for customization and expansion are endless.

11 views0 comments

Recent Posts

See All

Comentarios


bottom of page