diff options
-rw-r--r-- | exampleSite/config.toml | 1 | ||||
-rw-r--r-- | exampleSite/config_for_github_pages.toml | 1 | ||||
-rw-r--r-- | layouts/_default/baseof.html | 4 | ||||
-rw-r--r-- | layouts/partials/head.html | 12 |
4 files changed, 17 insertions, 1 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 89d6f20..4734534 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -6,3 +6,4 @@ theme = "grayscale" # Provide some metadata for search and indexing services description = "A port of the Grayscale theme to Hugo" author = "RunningStream" + #googleAnalytics = "" diff --git a/exampleSite/config_for_github_pages.toml b/exampleSite/config_for_github_pages.toml index 2ab2bc3..b91f90e 100644 --- a/exampleSite/config_for_github_pages.toml +++ b/exampleSite/config_for_github_pages.toml @@ -6,3 +6,4 @@ theme = "grayscale" # Provide some metadata for search and indexing services description = "A port of the Grayscale theme to Hugo" author = "RunningStream" + #googleAnalytics = "" diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index ab8d12d..674ae1b 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,6 +1,8 @@ <!doctype html> <html lang="{{ .Site.LanguageCode }}"> - {{- partial "head.html" . -}} + <head> + {{ partial "head.html" . }} + </head> <body id="page-top"> {{- partial "header.html" . -}} {{- block "main" . }}{{- end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 9e31330..21b9921 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -25,3 +25,15 @@ <!-- Custom styles for this template --> <link href="{{ "css/grayscale.min.css" | relURL }}" rel="stylesheet"> + + {{ with .Site.Params.googleAnalytics }} + <!-- Global site tag (gtag.js) - Google Analytics --> + <script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script> + <script> + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + + gtag('config', '{{ . }}'); + </script> + {{ end }} |