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 <noreply@anthropic.com>
This commit is contained in:
2026-08-08 19:26:04 +02:00
co-authored by Claude Sonnet 5
parent fe2cb13aff
commit 8a69ad41f2
@@ -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);