Set

To avoid the compelax searching process, I decide to note this easy method to finish it.

Firstly, you need set the env parameter and make it as below.

1
2
params:
  env: dev

Then you should edit the head of the config.yml.

1
2
3
4
googleAnalytics: G-XXX
privacy:
    googleAnalytics:
        disable: false

Lastly, you just add the command under the ../theme/layouts/_default/partials/head.html

1
2
3
{{ if not .Site.IsServer }}
{{ template "_internal/google_analytics.html" . }}
{{ end }}

Then you should run the code below on the teiminal to produce the “public” folder.

1
hugo --minify -e production

Then you just deploy it on the server again and wait a few minutes and it’ll appear on the Google Analytics website.