summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoramzrk22020-04-17 10:31:06 +0800
committeramzrk22020-04-17 10:31:06 +0800
commita2d3c7aa1e284f141e14481523f3488a65ccdbd7 (patch)
tree997ca86db3119d47ed2c4d8f882aacc49bfd4c34
parent19a1901a7ac7b756aa6d106f44e575ecd2c810ac (diff)
downloadhugo-theme-fuji-a2d3c7aa1e284f141e14481523f3488a65ccdbd7.tar.gz
hugo-theme-fuji-a2d3c7aa1e284f141e14481523f3488a65ccdbd7.tar.bz2
hugo-theme-fuji-a2d3c7aa1e284f141e14481523f3488a65ccdbd7.zip
Use site variable to set GA
-rw-r--r--exampleSite/config.toml6
-rw-r--r--layouts/partials/analytic-google.html8
2 files changed, 8 insertions, 6 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 6b7e189..8a39090 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -13,6 +13,9 @@ languageCode = "en"
summaryLength = 100 # Custom cummary length, add <!--more--> in post file to custom split point
paginate = 10
+# Set your Google Analytics UA here, or comment out to disable
+# googleAnalytics = "UA-000000000-0"
+
[permalinks]
post = "/:filename/" # Custom post links, e.g. "/:year/:month/:title/"
@@ -28,9 +31,6 @@ paginate = 10
# Posts shown in homepage
mainSections = ["post"]
- # Google Analytics
- googleAnalyticsUA = "UA-000000000-0"
-
# Bangumi image chart id
# bgmImageChart = "000000"
diff --git a/layouts/partials/analytic-google.html b/layouts/partials/analytic-google.html
index 2b5e74b..aa9915b 100644
--- a/layouts/partials/analytic-google.html
+++ b/layouts/partials/analytic-google.html
@@ -1,5 +1,6 @@
+{{ with .Site.GoogleAnalytics }}
<!-- Global site tag (gtag.js) - Google Analytics -->
-<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.googleAnalyticsUA }}"></script>
+<script async src="https://www.googletagmanager.com/gtag/js?id={{ . }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
@@ -7,5 +8,6 @@
dataLayer.push(arguments);
}
gtag('js', new Date());
- gtag('config', '{{ .Site.Params.googleAnalyticsUA }}');
-</script> \ No newline at end of file
+ gtag('config', '{{ . }}');
+</script>
+{{ end }} \ No newline at end of file