Skip to content

Commit

Permalink
update google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
JugglerX committed Jan 4, 2019
1 parent 98112e4 commit bc5c2ba
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
Binary file added images/screenshot-full.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot-full.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{{ block "title" . }}{{ .Title }} - {{ .Site.Title }}{{ end }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ block "meta_tags" . }}{{end}}
<link rel="icon" href="{{ .Site.BaseURL }}favicon.png">

{{ if .Site.IsServer }}
Expand Down
14 changes: 13 additions & 1 deletion layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
{{ define "title" }}{{ end}}
{{ define "title" }}Hugo Hero Theme Demo{{ end}}
{{ define "header_css" }}{{ end }}
{{ define "body_classes" }}page-home{{ end }}
{{ define "header_classes" }}header-transparent{{ end }}

{{ define "meta_tags" }}
<meta name="description" content="Hero is a multipurpose Hugo theme with fullscreen hero images and fullwidth sections. It contains content types for a business or portfolio site."/>
<meta property="og:title" content="Hugo Hero Theme" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://hugo-hero.netlify.com" />
<meta property="og:image" content="https://hugo-hero.netlify.com/screenshots/tn.png" />
<meta property="og:description" content="Hero is a multipurpose Hugo theme with fullscreen hero images and fullwidth sections. It contains content types for a business or portfolio site."/>
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@zerostaticio" />
<meta name="twitter:creator" content="@zerostaticio" />
{{ end }}

{{ define "main" }}

{{ partial "hero-image-fullscreen.html" (dict "background" "images/jason-blackeye-1191801-unsplash.jpg" "heading" "Hero - Hugo Small Business Theme" "subheading" "Hero is a multipurpose Hugo theme with fullscreen hero images and fullwidth sections. It contains content types for a business or portfolio site." "content" .)}}
Expand Down
18 changes: 10 additions & 8 deletions layouts/partials/google-analytics.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{{ if eq (getenv "HUGO_ENV") "production" }}
{{ if isset (getenv "HUGO_GOOGLE_ANALYTICS_ID") }}
{{- if .Site.IsServer -}}
<!-- Dont add Google analytics to localhost -->
{{ else }}
{{ $gid := (getenv "HUGO_GOOGLE_ANALYTICS_ID") }}
{{ if $gid }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{getenv "HUGO_GOOGLE_ANALYTICS_ID" }}"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{- $gid -}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{getenv "HUGO_GOOGLE_ANALYTICS_ID" }}');
gtag('config', '{{- $gid -}}');
</script>
{{ else }}
{{ if .Site.Params.google_analytics_id }}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.google_analytics_id }}"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id={{- .Site.Params.google_analytics_id -}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ .Site.Params.google_analytics_id }}');
gtag('config', '{{- .Site.Params.google_analytics_id -}}');
</script>
{{ end }}
{{ end}}
{{ end }}
{{ end }}
Binary file modified static/.DS_Store
Binary file not shown.

0 comments on commit bc5c2ba

Please sign in to comment.