Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/goodroot/hugo-classic.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Boyle <mail@christianboyle.com>2020-07-24 21:46:01 +0300
committerChristian Boyle <mail@christianboyle.com>2020-07-24 21:46:01 +0300
commita7f29151e81fd843ec6a56f7d1a2de57365115c6 (patch)
treeeaddf7a95bf6ee33aa8f2f06eca53b5e905abc80
parenta7352c4e715e9ea148893c2d6e5a77bc86007012 (diff)
Add support for Fathom Analytics
-rw-r--r--exampleSite/config.toml7
-rw-r--r--layouts/partials/analytics/fathom.html13
-rw-r--r--layouts/partials/footer.html3
3 files changed, 23 insertions, 0 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index f546f66..6af5db1 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -26,3 +26,10 @@ footnotereturnlinkcontents = "↩"
description = "A simple, minimal blog for those who love text."
footer = "Open-Source | [Github](https://github.com/goodroot/hugo-classic) | [Keybase](https://keybase.io/goodroot)"
custom_css = ["css/theme-override.css"]
+
+# If you want to use Fathom (https://usefathom.com) for analytics, add this section
+[params.fathomAnalytics]
+ siteID = "ABCDE"
+ # Default value is cdn.usefathom.com, overwrite this if you are self-hosting
+ serverURL = "analytics.example.com"
+
diff --git a/layouts/partials/analytics/fathom.html b/layouts/partials/analytics/fathom.html
new file mode 100644
index 0000000..13e7cfc
--- /dev/null
+++ b/layouts/partials/analytics/fathom.html
@@ -0,0 +1,13 @@
+<script>
+(function(f, a, t, h, o, m){
+ a[h]=a[h]||function(){
+ (a[h].q=a[h].q||[]).push(arguments)
+ };
+ o=f.createElement('script'),
+ m=f.getElementsByTagName('script')[0];
+ o.async=1; o.src=t; o.id='fathom-script';
+ m.parentNode.insertBefore(o,m)
+})(document, window, '//{{ .Site.Params.fathomAnalytics.serverURL | default "cdn.usefathom.com" }}/tracker.js', 'fathom');
+fathom('set', 'siteId', '{{ .Site.Params.fathomAnalytics.siteID }}');
+fathom('trackPageview');
+</script>
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 0a6c3f0..57ef8f3 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -5,5 +5,8 @@
{{ . | markdownify }}
{{ end }}
</footer>
+ {{ if and .Site.Params.fathomAnalytics .Site.Params.fathomAnalytics.siteID }}
+ {{- partial "analytics/fathom" . -}}
+ {{ end }}
</body>
</html>