GitHub Pages is a fantastic way to host your personal website, blog, or project documentation directly from a GitHub repository. Here’s a basic tutorial to get you started:
-
Create a GitHub Repository:
- Log in to your GitHub account and click on the ”+” sign in the top right corner.
- Select “New repository”.
- Give your repository a name. This name will be part of your website’s URL (e.g., username.github.io).
- Choose whether your repository will be public or private.
- Click on “Create repository”.
-
Set up your Repository:
- Once your repository is created, you’ll need to add your website files. For a basic setup, you’ll want an
index.html
file as the main page.
- You can create files directly on GitHub or push your local files to the repository.
-
Enable GitHub Pages:
- Go to your repository on GitHub.
- Click on the “Settings” tab.
- Scroll down to the “GitHub Pages” section.
- Under “Source”, select the branch where your website files reside. Typically, this is the
main
or master
branch.
- Click “Save”.
-
Access your Website:
- Once GitHub Pages is enabled, GitHub will give you a URL where your site is published (usually username.github.io).
- It may take a few moments for your site to become available.
-
Custom Domain (Optional):
- If you have a custom domain, you can configure GitHub Pages to use it.
- In your repository’s settings, under the “Custom domain” section, add your domain name.
- Update your domain’s DNS settings to point to GitHub’s servers. GitHub provides detailed instructions for this step.
-
Editing your Website:
- You can continue to edit your website by pushing changes to your GitHub repository.
- GitHub Pages will automatically update your site whenever you push changes to the repository.
-
Themes (Optional):
- If you want to use a Jekyll theme, you can do so by adding a
_config.yml
file to your repository.
- GitHub Pages supports Jekyll, a static site generator, which allows you to use themes and templates for your site.
That’s it! You now have a website hosted on GitHub Pages. From here, you can continue to refine and expand your site by adding new pages, blog posts, or project documentation. GitHub Pages offers a simple yet powerful platform for hosting your web content.