What Are the Steps to Publish a Jekyll Site on GitHub Pages?

Publishing your Jekyll site to GitHub Pages is a popular way to make your static website available online for free. If you're wondering how to go live with your site, this guide will walk you through every essential step, even if you’ve never used GitHub before.
Why Choose GitHub Pages for Hosting Your Jekyll Site?
There are many free and paid hosting services out there, but GitHub Pages is a perfect match for Jekyll because it's designed to serve static content directly from your repositories. Here are a few reasons why it's a smart choice:
- Free Hosting: Host personal, project, or organization sites at no cost.
- Automatic Integration: GitHub Pages natively supports Jekyll without needing a build server.
- Custom Domains: You can connect your custom domain to GitHub Pages easily.
- Version Control: Your content is always backed up with Git and can be easily rolled back.
How Do You Prepare Your Jekyll Site for Deployment?
Before you push your site to GitHub, it’s important to make sure everything is set up properly on your local machine. Here’s a checklist to follow:
1. Install Ruby and Jekyll Locally
Ensure you have Ruby installed. Then install Jekyll and Bundler using:
gem install jekyll bundler
2. Create or Finalize Your Jekyll Project
If you haven’t already created a site:
jekyll new my-awesome-site
Navigate into your directory:
cd my-awesome-site
3. Test It Locally
Run the following command to ensure your site builds correctly:
bundle exec jekyll serve
Then open http://localhost:4000
in your browser to preview it.
How Do You Push the Jekyll Site to GitHub?
Once your site works locally, it’s time to go live. Below is a step-by-step breakdown of pushing your site to GitHub:
1. Create a New Repository on GitHub
Log into your GitHub account, click “New Repository,” name it appropriately, and leave it public unless you’re using GitHub Pro.
2. Initialize Git in Your Project Directory
In your terminal, navigate to your project folder and run:
git init
git remote add origin https://github.com/yourusername/your-repo.git
3. Add and Commit Your Site Files
Use the following Git commands:
git add .
git commit -m "Initial site deployment"
4. Push the Site to GitHub
To push to the main branch:
git push -u origin main
5. Enable GitHub Pages in the Repository Settings
Go to the "Pages" section under your repository’s settings. Select the branch and folder (usually / (root)
or /docs
if using that structure), then save. GitHub will publish your site shortly.
Which Branch Should You Use for GitHub Pages?
Depending on the type of site, the branch setup differs:
Site Type | Recommended Branch | Notes |
---|---|---|
User or Organization Site | main | Repository must be named username.github.io |
Project Site | gh-pages | You must configure GitHub Pages to serve from this branch |
How Can You Automate Deployment for Jekyll Sites?
If you want your site to automatically rebuild every time you push changes, GitHub Actions can help. Add a workflow file like this:
name: Build and Deploy Jekyll site
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
with:
ruby-version: '3.1'
- run: gem install bundler jekyll
- run: bundle install
- run: bundle exec jekyll build
- run: git config user.name "GitHub Actions"
- run: git config user.email "[email protected]"
This ensures every update to your repository results in a fresh build and deployment.
Can You Use a Custom Domain with GitHub Pages?
Yes. To use a custom domain:
- Go to your repository settings under GitHub Pages
- Enter your custom domain (e.g.,
www.yoursite.com
) - Add a
CNAME
file to your root directory with the domain name - Update your DNS records (A and CNAME) to point to GitHub’s IP addresses
How Long Does It Take for Changes to Go Live?
Usually, GitHub Pages publishes changes within a minute. However, for new sites or DNS changes, it may take up to 24 hours to fully propagate, especially when using custom domains.
What Should You Do If Your GitHub Pages Site Is Not Updating?
If your site isn’t updating, check these common issues:
- Build Errors: Check your repository’s Actions tab for any failed build logs.
- Incorrect Branch: Ensure the right branch is selected under GitHub Pages settings.
- Caching: Clear your browser cache or use a private window to see the latest version.
Is It Safe to Host a Production Site on GitHub Pages?
GitHub Pages is reliable for personal and project-based static websites. However, it does have limitations:
- No support for server-side code (PHP, Python, etc.)
- Limited file types and maximum file size
- No database support
For most documentation, blogs, portfolios, and landing pages, it's more than adequate. But if your project grows or requires backend logic, you may want to migrate to a full-featured hosting provider.
How Do You Keep Your Jekyll Site Organized on GitHub?
To keep things clean and maintainable:
- Use meaningful commit messages
- Create a
README.md
with instructions and purpose of your site - Separate config files if using multiple environments
- Use GitHub branches for experimental changes
What’s Next After Going Live?
Congratulations! Your Jekyll site is live. Now, consider these enhancements:
- Enable HTTPS (default for GitHub Pages)
- Add Google Analytics or other tracking
- Submit your site to search engines for indexing
- Use Open Graph meta tags for better sharing
Can You Use Git Submodules with Jekyll on GitHub Pages?
Yes, but proceed with caution. Git submodules can be tricky. They’re useful for themes or content repos, but require correct `.gitmodules` config and consistent updates across your repo structure. GitHub Pages supports them only if correctly configured and updated before each push.
How Can You Optimize Your Jekyll Site for SEO on GitHub Pages?
Here are simple tips to ensure your Jekyll site performs well in search engines:
- Use descriptive
<title>
and metadescription
tags - Ensure your URLs are clean and keyword-rich
- Add a sitemap and robots.txt
- Use semantic HTML and responsive images
- Minify CSS and JS files
Conclusion
Publishing your Jekyll site on GitHub Pages is straightforward, fast, and free. By following the steps above—from preparing your local environment to customizing your domain—you can confidently go live with a secure, SEO-ready static website. With GitHub's infrastructure and Jekyll's simplicity, you now have the tools to build, host, and grow your online presence with ease.