---
title: "Jekyll Cookie Consent: GDPR Banner for GitHub Pages | CookieBeam"
description: "Add cookie consent to Jekyll and GitHub Pages. One script tag in _includes/head.html, automatic cookie blocking, and Google Consent Mode support."
url: "https://cookiebeam.com/guides/jekyll-cookie-consent-guide-2026"
lang: "en"
last_updated: "2026-10-17T18:54:18.460Z"
---

# Jekyll Cookie Consent: Add GDPR Compliance to Your GitHub Pages Site

How to add a cookie consent banner to a Jekyll site hosted on GitHub Pages. Covers _includes setup, blocking analytics scripts, and working within Jekyll's static-site constraints.

## Jekyll and cookies: what you need to know

Jekyll generates static HTML. No server, no database, no session cookies by default. But the moment you add Google Analytics, a comments widget, an embedded YouTube video, or any third-party JavaScript, your site sets cookies. And if EU visitors land on your site, you need their consent first.

GitHub Pages makes this trickier because you can't run server-side code. Everything has to work client-side. The good news: a consent management script runs entirely in the browser, so it works perfectly on GitHub Pages.

Place the CookieBeam loader as the first element in `<head>`, loaded synchronously before GTM, analytics, or other scripts. Do not add `async` or `defer`, and exclude it from script-delay optimizers.

## Quick setup

Add the CookieBeam script to your Jekyll site's head include. Open `_includes/head.html` (or `_includes/head-custom.html` if you're using a remote theme) and add this as the first element in `<head>`, loaded synchronously:

```
<script src="https://cdn.cookiebeam.com/banner/YOUR_BANNER_ID/default/loader.js"></script>
```

Replace `YOUR_BANNER_ID` with your banner ID from the CookieBeam dashboard. That's it. Every page that uses this include now has cookie consent.

## Blocking Google Analytics until consent

If you're using Jekyll's built-in Google Analytics support (the `google_analytics` config key), the tracking script loads unconditionally. To make it consent-aware:

### Option 1: Gate the hardcoded analytics tag

CookieBeam's auto-blocking detects the Google Analytics script and blocks it until the visitor consents. Hardcoded GA tags need inert markup with `type="text/plain" data-category="analytics" data-src`.

### Option 2: Conditional include with Liquid

Create a custom analytics include that only outputs the script tag when consent is given. Since Jekyll is static, you can't check consent at build time, but you can use CookieBeam's JavaScript API to conditionally load scripts at runtime.

> **Note: GitHub Pages and custom domains**
>
> If your Jekyll site uses a custom domain (not username.github.io), make sure the domain is listed in your CookieBeam banner's allowed domains. The consent banner validates the domain it's running on to prevent unauthorized use of your banner ID.

### Does this work with GitHub Pages?

Yes. CookieBeam is a client-side script that runs entirely in the browser. It doesn't need a server, so it works on GitHub Pages, Netlify, Vercel, or any static host.

### Will it slow down my Jekyll site?

The CookieBeam script is under 15KB gzipped. It loads synchronously as the first script in `<head>`, which is what lets it hold back trackers before they run (see the [load order docs](https://cookiebeam.com/docs/configure/load-order)). Jekyll sites are already fast because they're static HTML; the consent script adds minimal overhead.

### I use a Jekyll theme that I can't modify. Can I still add consent?

Most Jekyll themes support _includes/head-custom.html for adding custom scripts without modifying the theme. If yours doesn't, you can add the script via a Jekyll plugin or directly in your layout file.
