I had google analytics enabled for my site and I have the following line in Single.html.
{{ template "_internal/google_analytics_async.html" . }}
I have now updated it to
{{ if not (in (.Site.BaseURL | string) "localhost") }}
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}
so that it does not load GA for localhost. Is this good enough? In F12 developer options, I still see GA loading on the page.
Hi @rchaganti, you should use this instead {{ if .Site.IsServer }}.
You meant like this?
{{ if not .Site.IsServer }}
{{ template "_internal/google_analytics_async.html" . }}
{{ end }}
I have this in both layouts/blog/single.html and layouts/index.html. I still see the GA related elements in the generated HTML.

I have the following line in Single.html.
I didn't saw that, you have to update the baseof.html file, not this one. The GA line is already written(line 116), you just have to surround it with the condition.
Perfect! Thank you!