I am trying to get my Hugo site working with Google Analytics. I have added the partial template from Hugo to my head.html partial:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{ if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }}</title>
{{ range .Site.Params.author -}}
<meta name="author" content="{{ .name | default " Jeffrey Lebowski" }}" />
{{ end -}}
<meta name="description"
content="{{- if .Description -}}{{- .Description -}}{{- else -}}{{- .Site.Params.Description -}}{{- end -}}" />
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ $style := resources.Get "sass/main.scss" | resources.ExecuteAsTemplate "sass/main.scss" . | resources.ToCSS |
resources.Minify | resources.Fingerprint -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}" />
{{ $syntax := resources.Get "css/syntax.css" | resources.Minify | resources.Fingerprint -}}
<link rel="stylesheet" href="{{ $syntax.RelPermalink }}" />
{{ $image := resources.GetMatch "images/favicon.ico"}}
{{ if $image }}
<link rel="icon" type="image/ico" href="{{ $image.RelPermalink }}" />
<link rel="shortcut icon" type="image/ico" href="{{ $image.RelPermalink }}" />
{{ else }}
{{ $image := resources.GetMatch "images/favicon.png"}}
{{ if $image }}
<link rel="icon" type="image/png" href="{{ $image.RelPermalink }}" />
<link rel="shortcut icon" type="image/png" href="{{ $image.RelPermalink }}" />
{{ end }}
{{ end }}
{{ template "_internal/twitter_cards.html" . }}
{{ template "_internal/opengraph.html" . }}
{{ template "_internal/google_analytics.html" . }}
I have added my ID to the config.toml of my site using the following:
[services]
[services.googleAnalytics]
ID = ‘’
However, when I test locally the partial template for doesn’t appear in my head. It loads the Twitter cards template and the open graph template but doesn’t load the google analytics template.
Am I doing something wrong? How do I get my head.html to load the Google Anaylitcs template?