From 3f511f5e6f6df467eb935e238a848508d89fef3c Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Sat, 8 Aug 2026 19:25:56 +0200 Subject: [PATCH] Log a clear console error when the cookie banner is missing Silently returning made a missing banner.html integration indistinguishable from a working page, which cost real debugging time. Fail loud instead, pointing at the README. Co-Authored-By: Claude Sonnet 5 --- assets/js/hugo_cookie_consent/cookie_consent.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/assets/js/hugo_cookie_consent/cookie_consent.js b/assets/js/hugo_cookie_consent/cookie_consent.js index 2573f97..b359e6e 100644 --- a/assets/js/hugo_cookie_consent/cookie_consent.js +++ b/assets/js/hugo_cookie_consent/cookie_consent.js @@ -1,7 +1,14 @@ (function () { var KEY = 'cookie_consent'; var banner = document.getElementById('cookie-banner'); - if (!banner) return; + if (!banner) { + console.error( + '[hugo_cookie_consent] #cookie-banner not found in the DOM. ' + + 'Did you include the hugo_cookie_consent/banner.html partial in your site\'s layout? ' + + 'See the module README ("Installation in your Hugo site").' + ); + return; + } updateStatus(); var consent = localStorage.getItem(KEY);