diff --git a/site/config.yaml b/site/config.yaml index 9edc08541..781878b36 100644 --- a/site/config.yaml +++ b/site/config.yaml @@ -7,6 +7,7 @@ frontmatter: date: [":filename", ":default"] params: author: Velero Authors + googleAnalytics: G-XX7MWLVX37 logo: Velero.svg cncf_logo: cncf-color.svg hero: diff --git a/site/layouts/_default/baseof.html b/site/layouts/_default/baseof.html index 46d706fd2..e6910c6b9 100644 --- a/site/layouts/_default/baseof.html +++ b/site/layouts/_default/baseof.html @@ -10,6 +10,7 @@ {{ $styles := resources.Get "styles.scss" | toCSS $options | resources.Fingerprint }} {{ block "siteTitle" . }}{{ .Site.Title }} {{ .Page.Title }}{{ end }} + {{ partial "google-analytics.html" . }}
diff --git a/site/layouts/partials/google-analytics.html b/site/layouts/partials/google-analytics.html new file mode 100644 index 000000000..c85bdbc70 --- /dev/null +++ b/site/layouts/partials/google-analytics.html @@ -0,0 +1,19 @@ +{{/* + Google Analytics 4 (gtag.js). + + Renders only in production builds (Netlify runs `hugo` with the production + environment, so local `hugo server` and PR previews stay out of the data). + The Measurement ID is read from `params.googleAnalytics` in config.yaml. +*/}} +{{ if hugo.IsProduction }} +{{ with .Site.Params.googleAnalytics }} + + + +{{ end }} +{{ end }} diff --git a/site/layouts/partials/head-docs.html b/site/layouts/partials/head-docs.html index c92837b2f..8cbb917ed 100644 --- a/site/layouts/partials/head-docs.html +++ b/site/layouts/partials/head-docs.html @@ -8,4 +8,5 @@ {{ $styles := resources.Get "styles.scss" | toCSS $options | resources.Fingerprint }} {{/* TODO {% seo %}*/}} + {{ partial "google-analytics.html" . }}