From 10125d8fe1dae8b95ba3df96c419a369fac3eac5 Mon Sep 17 00:00:00 2001 From: Mike Bergeron Date: Wed, 4 Jul 2018 05:29:28 -0700 Subject: Use Hugo's internal templates for Google Analytics (GA) (#36) * Use Hugo's internal templates for Google Analytics (GA) This commit does the following: * Removes a hardcoded Google Analytics ID * Converts the layout to use Hugo's internal GA teamplate * Removes the configuration items from the example site * Adds a section to the README about what internal templates are supported. For more info about the GA internal template, see this URL: https://gohugo.io/templates/internal/#configure-google-analytics Signed-off-by: Michael Bergeron * Add Google Analytics config into exampleSite * Add google analytics template to single.html * Bump version to 3.0.0 Breaking change based on google analytics configuration --- README.md | 6 ++++++ exampleSite/config-prod.toml | 2 +- exampleSite/config.toml | 2 +- layouts/_default/single.html | 3 ++- layouts/index.html | 1 + layouts/partials/scripts/googleanalytics.html | 11 ----------- layouts/partials/scripts/index.html | 1 - package-lock.json | 2 +- package.json | 2 +- 9 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 layouts/partials/scripts/googleanalytics.html diff --git a/README.md b/README.md index 3e31094..fbbe817 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,12 @@ See the demo's configuration as an example: https://github.com/curttimson/hugo-theme-massively/blob/master/exampleSite/config-prod.toml +#### Hugo Internal Templates + +The theme currently also supports the following ["internal templates" supplied by Hugo](https://gohugo.io/templates/internal/) + + - [Google Analytics](https://gohugo.io/templates/internal/#configure-google-analytics) + ### Cover Image The cover image URL is hard-coded, therefore to replace this add an image to the following location in your Hugo application: diff --git a/exampleSite/config-prod.toml b/exampleSite/config-prod.toml index f7b7c87..1ddd58e 100644 --- a/exampleSite/config-prod.toml +++ b/exampleSite/config-prod.toml @@ -2,6 +2,7 @@ languageCode = "en-us" title = "Massively" baseURL = "https://hugo-theme-massively.netlify.com/" theme = "../.." +googleanalytics = "UA-113904582-4" # [params] # set below parameter to define a favicon @@ -14,7 +15,6 @@ theme = "../.." # featuredpost = "true" [params.settings] - googleanalytics = "UA-113904582-4" disqus = "hugo-massively" [languages] diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 4e4cbd0..902552c 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -2,6 +2,7 @@ languageCode = "en-us" title = "Massively" baseURL = "http://localhost:1313/" theme = "../.." +googleanalytics = "UA-113904582-3" # [params] # set below parameter to define a favicon @@ -14,7 +15,6 @@ theme = "../.." # featuredpost = "true" [params.settings] - googleanalytics = "UA-113904582-3" disqus = "hugo-massively" [languages] diff --git a/layouts/_default/single.html b/layouts/_default/single.html index f1b3f27..5860e0b 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -36,7 +36,8 @@ {{ partial "footer/index" . }} {{ partial "copyright" . }} - + + {{ template "_internal/google_analytics.html" . }} {{ partial "scripts/index" . }} diff --git a/layouts/index.html b/layouts/index.html index b45fb1c..ae90e4d 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -60,6 +60,7 @@ {{ partial "copyright" . }} + {{ template "_internal/google_analytics.html" . }} {{ partial "scripts/index" . }} diff --git a/layouts/partials/scripts/googleanalytics.html b/layouts/partials/scripts/googleanalytics.html deleted file mode 100644 index 98a3c47..0000000 --- a/layouts/partials/scripts/googleanalytics.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ if .Site.Params.Settings.googleanalytics }} - - - -{{ end }} \ No newline at end of file diff --git a/layouts/partials/scripts/index.html b/layouts/partials/scripts/index.html index 92c8ed9..2c4ef29 100644 --- a/layouts/partials/scripts/index.html +++ b/layouts/partials/scripts/index.html @@ -6,5 +6,4 @@ -{{ partial "scripts/googleanalytics" . }} {{ partial "scripts/disqus" . }} diff --git a/package-lock.json b/package-lock.json index d4fb0aa..983a30a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "hugo-theme-massively", - "version": "2.2.0", + "version": "2.2.2", "lockfileVersion": 1 } diff --git a/package.json b/package.json index b0babcc..db589b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hugo-theme-massively", - "version": "2.2.2", + "version": "3.0.0", "description": "HTML5 UP theme Massively for Hugo", "main": "index.js", "scripts": { -- cgit v1.2.3