Skip to main content
CookieBeam
Back to Guides
Setup2 min readBy Armin Zaribaf

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.

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.

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). 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.

6 min read

Manage CookieBeam from ChatGPT or Claude

Connect an AI assistant to your CookieBeam account over MCP and manage banners, scans and analytics from a conversation. Covers connecting, what the assistant can do, example prompts, access control and known limits.

8 min read

Shopify Cookie Consent: GDPR and CCPA Setup Guide for 2026

Shopify's built-in cookie banner covers the basics, but falls short for stores selling into the EU, California, or multiple regions at once. This guide walks through what Shopify gives you, where it stops, and how to add a proper consent layer with CookieBeam.

4 min read

Remix Cookie Consent: Server-Side Rendering and GDPR

Add GDPR-compliant cookie consent to a Remix app. Covers script placement in root.tsx, streaming SSR considerations, consent-aware loaders, and the framework-specific quirks that trip up most implementations.

AltStyle によって変換されたページ (->オリジナル) /