mirror of
https://github.com/chaoming/hugo-saasify-theme.git
synced 2025-04-20 05:41:52 +02:00
added Google Analytics support
This commit is contained in:
parent
a89df57429
commit
425ed160f0
4 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<!-- Google Analytics -->
|
||||
{{ partial "google-analytics" . }}
|
||||
|
||||
<!-- Title -->
|
||||
<title>{{ if .IsHome }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }}</title>
|
||||
|
||||
|
|
10
layouts/partials/google-analytics.html
Normal file
10
layouts/partials/google-analytics.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{ if and hugo.IsProduction .Site.Params.googleAnalytics }}
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.googleAnalytics }}"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', '{{ .Site.Params.googleAnalytics }}');
|
||||
</script>
|
||||
{{ end }}
|
Loading…
Add table
Reference in a new issue