* feat: add GDPR cookie consent banner
Add a GDPR-compliant cookie consent banner that gates analytics (Google
Analytics) and functional cookies (comments) until user consent is given.
Features:
- Theme-consistent styling using CSS variables (light/dark mode)
- Settings panel with category toggles (necessary, analytics, functional)
- Consent stored in cookie for 365 days
- Google Analytics only loads after analytics consent
- Comments only load after functional consent
- Translations for all 32 supported languages
- Accessible with proper ARIA attributes and focus management
Configuration in hugo.yaml:
params:
cookies:
enabled: true
categories:
analytics: true
functional: true
When cookies.enabled is false, scripts load normally without consent gating.
Closes #412
* refactor: move consent-gated GA to cookies/analytics.html
Move Google Analytics consent logic to avoid shadowing Hugo's internal
`_internal/google_analytics.html` template.
Changes:
- Rename google_analytics.html → cookies/analytics.html
- Update head.html to conditionally load:
- cookies.enabled=true: cookies/analytics.html (consent-gated)
- cookies.enabled=false: Hugo's _internal/google_analytics.html
- Align cookies/analytics.html with Hugo's internal template:
- Support Privacy.GoogleAnalytics.Disable setting
- Support Privacy.GoogleAnalytics.RespectDoNotTrack setting
- Add UA- prefix deprecation warning
Note: Custom JS is required for consent-gated GA because Hugo templates
render at build time, but consent happens at runtime. We cannot call
Hugo's internal template after the user grants consent - we must
dynamically inject the GA script via JavaScript.
* style: indent cookies/analytics.html
* refactor: don't use default, put default configurations in params.toml
* fix: don't use `description` as translation key because it's reserved and will throw error
* fix: remove footer/components/custom-font.html call
* fix: banner showSettings key
* style: indent comments/include
* Add missing article.alert translation back
* style: format i18n toml files
* style: indent head/head.html
* style adjustment
* style: add missing -
* style: format demo/config/params.toml
* style: remove redundant comments from cookies.scss
* style: update box-shadow for cookie banner content
---------
Co-authored-by: delize <4028612+delize@users.noreply.github.com>
Co-authored-by: Jimmy Cai <jimmy@cai.im>
79 lines
2.3 KiB
TOML
79 lines
2.3 KiB
TOML
toggleMenu = "Ocultar menú"
|
|
darkMode = "Modo oscuro"
|
|
|
|
[list]
|
|
section = "Sección"
|
|
|
|
[list.page]
|
|
one = "{{ .Count }} página"
|
|
other = "{{ .Count }} páginas"
|
|
|
|
[list.subsection]
|
|
one = "Subsección"
|
|
other = "Subsecciones"
|
|
|
|
[article]
|
|
back = "Volver"
|
|
tableOfContents = "Tabla de contenido"
|
|
relatedContent = "Contenidos relacionados"
|
|
lastUpdatedOn = "Última actualización"
|
|
|
|
[article.readingTime]
|
|
one = "Tiempo de lectura {{ .Count }} minuto"
|
|
other = "Tiempo de lectura {{ .Count }} minutos"
|
|
|
|
[article.alert]
|
|
note = "Nota"
|
|
tip = "Consejo"
|
|
important = "Importante"
|
|
warning = "Advertencia"
|
|
caution = "Precaución"
|
|
|
|
[notFound]
|
|
title = "No Encontrado"
|
|
subtitle = "Esta página no existe"
|
|
|
|
[widget]
|
|
[widget.archives]
|
|
title = "Archivo"
|
|
more = "Más"
|
|
|
|
[widget.tagCloud]
|
|
title = "Etiquetas"
|
|
|
|
[widget.categoriesCloud]
|
|
title = "Categorías"
|
|
|
|
[search]
|
|
title = "Búsqueda"
|
|
placeholder = "Escribe algo..."
|
|
resultTitle = "#PAGES_COUNT páginas en (#TIME_SECONDS segundos)"
|
|
|
|
[footer]
|
|
builtWith = "Creado con {{ .Generator }}"
|
|
designedBy = "Tema {{ .Theme }} diseñado por {{ .DesignedBy }}"
|
|
|
|
[cookies]
|
|
title = "Consentimiento de cookies"
|
|
text = "Utilizamos cookies para mejorar su experiencia de navegación y analizar el tráfico del sitio."
|
|
acceptAll = "Aceptar todo"
|
|
deny = "Rechazar"
|
|
managePreferences = "Gestionar preferencias"
|
|
settingsTitle = "Preferencias de cookies"
|
|
savePreferences = "Guardar preferencias"
|
|
cancel = "Cancelar"
|
|
footerLink = "Configuración de cookies"
|
|
commentsDisabled = "Los comentarios están desactivados hasta que acepte las cookies funcionales."
|
|
|
|
[cookies.necessary]
|
|
title = "Necesarias"
|
|
text = "Estas cookies son necesarias para el funcionamiento del sitio web y no se pueden desactivar."
|
|
|
|
[cookies.analytics]
|
|
title = "Analíticas"
|
|
text = "Estas cookies nos ayudan a entender cómo los visitantes interactúan con nuestro sitio web."
|
|
|
|
[cookies.functional]
|
|
title = "Funcionales"
|
|
text = "Estas cookies permiten funciones como comentarios y contenido incrustado."
|