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.
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 before the closing </head>:
<script src="https://cdn.cookiebeam.com/banner/YOUR_BANNER_ID/default/loader.js" async></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: Let CookieBeam auto-block it
CookieBeam's auto-blocking detects the Google Analytics script and blocks it until the visitor consents. If you load GA via a standard script tag, this works automatically.
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.