Custom alias.html containing partial that references a .Site vars results in runtime error

Any ideas why this would be happening… I’m trying to get Google Analytics on this page.


<!DOCTYPE html>

  <title>{{ .Permalink | absURL }}</title>
  <link rel="canonical" href="{{ .Permalink | absURL }}" />
  <meta name="robots" content="noindex">
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta http-equiv="refresh" content="10; url={{ .Permalink | absURL }}" />
  {{ partial "googleAnalytics" . }}



  gaNumber = "GA-12345678"

Partial {{ partial “googleAnalytics” . }}

{{ if .Site.Params.googleTagManager }}
  (function (w, d, s, l, i) {
    w[l] = w[l] || []; w[l].push({
        new Date().getTime(), event: 'gtm.js'
    var f = d.getElementsByTagName(s)[0],
      j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
    j.async = true; j.src = '' + i + dl;
    f.parentNode.insertBefore(j, f);
  })(window, document, 'script', 'dataLayer', '{{ .Site.Params.gaNumber }}');

  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments) };
  gtag('js', new Date());
  gtag('config', '{{ .Site.Params.gaNumber }}'{{ if .Params.preventGoogleTracking | default false }} , { 'send_page_view': false } {{ end }});
{{ end }}

Error: Error building site: failed to render pages: execute of template failed: template: alias.html:10:5: executing “alias.html” at <partial “googleAnalytics” .>: error calling partial: “/layouts/partials/googleAnalytics.html:1:11”: execute of template failed: template: partials/googleAnalytics.html:1:11: executing “partials/googleAnalytics.html” at <.Site.Params.gaNumber >: error calling Site: runtime error: invalid memory address or nil pointer dereference



Wait, what?

What does the phone have to do with Google Analytics? Please, please, please use more words.

Why would a header-tag use span tags? And again… what? What does Google Analytics have to do with a phone number?

Sorry I made that more complicated than it needed to be… I have revised to make more sense.

What does your template do different than the internal Google Analytics template?

Your sample should not throw any error. If so, post the full code and the full error that comes up.

It’s not an internal template because its for Google Tag Manager… Updated code above