Using google analytics internal template in footer partial

How do I use the http://gohugo.io/extras/analytics/ internal template in my footer partial?

I’ve tried

 {{ partial "_internal/google_analytics_async.html" . }}

and

{{ template "_internal...." }}

Like in the doc, but I get
no such template "_internal/google_analytics_async.html" in partials/...
and

ERROR: 2016/03/31 Unable to render [partials/_internal/google_analytics_async.html theme/partials/_internal/google_analytics_async.html]
ERROR: 2016/03/31 Expecting to find a template in either the theme/layouts or /layouts in one of the following relative locations [partials/_internal/google_analytics_async.html theme/partials/_internal/google_analytics_async.html]

If I add the {{ template ... }} to the index.html of my layouts it works for the index, but I can’t completly figure out how many files I need to add it to - given I use an external theme and all - if that is the way to go anyway?

Turns out its _async that’s the issue. It works with the sync template. (and it didn’t work in index.html with _async either)

I spent about an hour trying to debug this as well, and came up with an answer:

The current release of Hugo appears to be 0.15 it’s the most recent tag in GitHub.

The added functionality of the async template was merged to master in: https://github.com/spf13/hugo/commit/ff28120e53c7d3d5fce9941082f72eb89adb43b7
(original issue)

There has yet to be a release that contains this commit.

A workaround for now would be to build hugo from master, or use the sync mode until the release.

@miketheman Your oberservation is right. The template was accidently added in February (see commit) while documenting the Google Analytics templates at all (including the non-async version).

In the next future the should be a new release of Hugo including the async template. This is no official announcement but we currently started a feature-freeze.

1 Like