From 425ed160f0e82cfbf4c11383a2544f2a66f2e36d Mon Sep 17 00:00:00 2001 From: Chaoming Li Date: Sat, 30 Nov 2024 22:31:23 +1100 Subject: [PATCH] added Google Analytics support --- README.md | 4 ++++ exampleSite/hugo.toml | 2 ++ layouts/_default/baseof.html | 3 +++ layouts/partials/google-analytics.html | 10 ++++++++++ 4 files changed, 19 insertions(+) create mode 100644 layouts/partials/google-analytics.html diff --git a/README.md b/README.md index 89bbcd6..dac9a20 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ A modern and elegant Hugo theme specifically designed for SaaS websites. Built w - 🎯 Perfect for SaaS and business websites - 🛠 Easy to customize - 📦 No jQuery, minimal JavaScript +- 📊 Google Analytics support ## Requirements @@ -159,6 +160,8 @@ enableGitInfo = true # Enable Git info for lastmod description = "Your site description" author = "Your Name" logo = "/images/logo.svg" # Path to your logo + # Google Analytics ID (e.g., "G-XXXXXXXXXX") + googleAnalytics = "G-XXXXXXXXXX" # Only enabled in production # Header Configuration [params.header] @@ -228,6 +231,7 @@ This configuration includes: - Header configuration with logo and navigation - Call-to-action (CTA) sections - Social media links + - Google Analytics configuration (only enabled in production) - **Navigation Menu**: Main menu structure with dropdown support ## Development diff --git a/exampleSite/hugo.toml b/exampleSite/hugo.toml index 1d3fc0e..729bb67 100644 --- a/exampleSite/hugo.toml +++ b/exampleSite/hugo.toml @@ -28,6 +28,8 @@ paginatePath = "page" description = "" author = "Chaoming Li" logo = "/images/logo.svg" + # Google Analytics ID (e.g., "G-XXXXXXXXXX") + # googleAnalytics = "G-XXXXXXXXXX" # Global CTA Configuration [params.cta] diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 0dc2265..3317cf9 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -4,6 +4,9 @@ + + {{ partial "google-analytics" . }} + {{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }} diff --git a/layouts/partials/google-analytics.html b/layouts/partials/google-analytics.html new file mode 100644 index 0000000..3a31f44 --- /dev/null +++ b/layouts/partials/google-analytics.html @@ -0,0 +1,10 @@ +{{ if and hugo.IsProduction .Site.Params.googleAnalytics }} + + + +{{ end }}