Use hugo template for google analytics

https://gohugo.io/templates/internal/#use-the-google-analytics-template
This commit is contained in:
Djordje Atlialp 2020-04-16 08:35:22 +02:00
parent 2665270e50
commit 6ee1cf6892

View file

@ -6,18 +6,11 @@
<script type="text/javascript" src="{{ $secureJS.RelPermalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
{{- if .Site.GoogleAnalytics }}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{.Site.GoogleAnalytics}}', 'auto');
ga('send', 'pageview');
</script>
{{ template "_internal/google_analytics.html" . }}
{{- end}}
{{ range $val := $.Site.Params.customJS }}
{{ if gt (len $val) 0 }}
<script src="{{ $val }}"></script>
{{ end }}
{{ if gt (len $val) 0 }}
<script src="{{ $val }}"></script>
{{ end }}
{{ end }}