diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | layouts/partials/head.html | 4 |
2 files changed, 5 insertions, 1 deletions
@@ -110,6 +110,8 @@ If you *don't* have the section `[Params.staticman]` in `config.toml`, you *won' To add Google Analytics, simply sign up to [Google Analytics](https://www.google.com/analytics/) to obtain your Google Tracking ID, and add this tracking ID to the `googleAnalytics` parameter in `config.toml`. +Note that the Google Analytics tracking code will only be inserted into the page when the site isn't served on Hugo's built-in server, to prevent tracking from local testing environments. + ### Commit SHA on the footer If the source of your site is in a Git repo, the SHA corresponding to the commit the site is built from can be shown on the footer. To do so, two site parameters `commit` has to be defined in the config file `config.toml`: diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 83ace10..de9a5a3 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -88,4 +88,6 @@ {{- end -}} {{- partial "head_custom.html" . }} -{{ template "_internal/google_analytics_async.html" . }} +{{- if not .Site.IsServer -}} + {{ template "_internal/google_analytics_async.html" . }} +{{- end -}}
\ No newline at end of file |