ade's notes

Automating Jekyll Deployment to GitHub Pages with GitHub Actions

This guide shows how to build and deploy a Jekyll site to GitHub Pages using GitHub Actions. GitHub Pages will serve your site directly from the artifact built in the workflow.


Table of Contents

  1. Overview

  2. Requirements

  3. Repository Setup

  4. Jekyll Site Structure

  5. Creating the Deployment Workflow

  6. Configuring GitHub Pages

  7. Deploying the Site

  8. Troubleshooting


1. Overview

We’ll use a GitHub Actions workflow to:


2. Requirements

You need:


3. Repository Setup

Your project should include the following files:

.
├── _config.yml
├── index.md
├── _posts/
├── _layouts/
├── Gemfile
├── Gemfile.lock
└── .github/
    └── workflows/
        └── gh-pages.yml

Ensure Gemfile includes at minimum:

source "https://rubygems.org"
gem "jekyll"

Run locally:

bundle install

Commit both Gemfile and Gemfile.lock.


4. Jekyll Site Structure

Make sure your Jekyll site has a valid _config.yml. Example:

title: My Site
baseurl: "" # Leave empty for apex or user site
url: "https://username.github.io" # or your custom domain

You can test locally with:

bundle exec jekyll serve

5. Creating the Deployment Workflow

Create the file .github/workflows/gh-pages.yml with the following contents:

name: GitHub Pages

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  workflow_dispatch:

permissions:
  contents: write
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: $

    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Set up Ruby
      uses: ruby/setup-ruby@v1
      with:
        ruby-version: '3.1.6'
        bundler-cache: true

    - name: Install dependencies
      run: |
        gem install bundler
        bundle install --without debug

    - name: Build Jekyll site
      run: |
        bundle exec jekyll build

    - name: Setup GitHub Pages
      uses: actions/configure-pages@v4

    - name: Upload artifact for GitHub Pages
      uses: actions/upload-pages-artifact@v3
      with:
        path: ./_site

    - name: Deploy to GitHub Pages
      id: deployment
      uses: actions/deploy-pages@v4

6. Configuring GitHub Pages

To enable deployment from GitHub Actions:

  1. Go to your repository → Settings

  2. Click Pages in the sidebar

  3. Under Build and deployment, set:

    • Source: GitHub Actions

You do not need to choose a branch or folder. The workflow handles it.


7. Deploying the Site

Once the gh-pages.yml workflow is committed and pushed:

git add .
git commit -m "Set up automated Jekyll deployment"
git push origin main

Go to the Actions tab and watch the GitHub Pages workflow run. Once it finishes, your site will be live at:


8. Troubleshooting

My site doesn’t deploy

No HTTPS?

Caching or dependency issues?

Delete your vendor/ folder and try:

bundle update

See Also