วันอาทิตย์ที่ 23 สิงหาคม พ.ศ. 2569

Using GitHub pages to build static websites

 1. Create a Repository

  1. Log in to GitHub.
  2. Click the + icon in the top-right corner and select New repository.
  3. Under Repository name, type username.github.io (replace username with your exact GitHub username in lowercase).
  4. Set the visibility to Public (required for free accounts).
  5. Check the box to Add a README file.
  6. Click Create repository.
2. Add Website Files
  1. Inside your new repository, click Add file and select Create new file (or Upload files if you already have files ready on your computer).
  2. Name your primary file index.html“IMPORTANT: Your homepage HTML file must be called "index.html", and it must exist in the top-level directory.” -- [Tyler Fisher / GitHub Gist].
  3. Add basic HTML content to the file, such as:
    html
    <!DOCTYPE html>
    <html>
    <head>
        <title>My GitHub Website</title>
    </head>
    <body>
        <h1>Hello, world!</h1>
    </body>
    </html>
    
    Use code with caution.
  4. Scroll down and click Commit changes to save the file.
3. Activate GitHub Pages
  1. Navigate to the Settings tab under your repository name.
  2. In the left sidebar under the "Code and automation" section, click Pages.
  3. Under Build and deployment, locate the "Source" dropdown and ensure Deploy from a branch is selected.
  4. Under Branch, change the dropdown from "None" to main (or master).
  5. Leave the folder as / (root) and click Save.
4. Visit Your Live Site
  1. Wait 1 to 2 minutes for GitHub to process the deployment.
  2. Open a web browser and type https://username.github.io (swapping in your actual username). Your site is now live to the public!