diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index c050aee..5d28278 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -4,3 +4,52 @@ description = "Bridget is a minimal Hugo theme designed for photographers / visu # * if you want to build the js and css from scratch, set this to false and run `npm install` and `npm run build` # * tldr: set this to false if you want to edit the js and css bundled = false + +# Site verification code for Google/Bing/Yandex/Pinterest/Baidu +[verification] +google = "" +bing = "" +yandex = "" +pinterest = "" +baidu = "" +so = "" +sogou = "" + +# Analytics config +[analytics] +enable = false +# Google Analytics +[analytics.google] +id = "" +# whether to anonymize IP +anonymizeIP = true +# Fathom Analytics +[analytics.fathom] +id = "" +# server url for your tracker if you're self hosting +server = "" +# Baidu Analytics +[analytics.baidu] +id = "" +# Umami Analytics +[analytics.umami] +data_website_id = "" +src = "" +data_host_url = "" +data_domains = "" +# Plausible Analytics +[analytics.plausible] +data_domain = "" +src = "" +# Cloudflare Analytics +[analytics.cloudflare] +token = "" +# Splitbee Analytics +[analytics.splitbee] +enable = false +# no cookie mode +No_cookie = true +# respect the do not track setting of the browser +Do_not_track = true +# token(optional), more info on https://splitbee.io/docs/embed-the-script +data_token = "" diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 2dade46..19f9ec4 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -13,5 +13,8 @@ {{- block "main" . -}} {{- end -}} +
+ {{- partial "plugin/analytics.html" . -}} +
diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html index e69de29..f49d864 100644 --- a/layouts/partials/head/seo.html +++ b/layouts/partials/head/seo.html @@ -0,0 +1,21 @@ +{{- with site.Params.verification.google -}} + +{{- end -}} +{{- with site.Params.verification.bing -}} + +{{- end -}} +{{- with site.Params.verification.yandex -}} + +{{- end -}} +{{- with site.Params.verification.pinterest -}} + +{{- end -}} +{{- with site.Params.verification.baidu -}} + +{{- end -}} +{{- with site.Params.verification.sogou -}} + +{{- end -}} +{{- with site.Params.verification.so -}} + +{{- end -}} diff --git a/layouts/partials/plugin/analytics.html b/layouts/partials/plugin/analytics.html new file mode 100644 index 0000000..ef18f45 --- /dev/null +++ b/layouts/partials/plugin/analytics.html @@ -0,0 +1,84 @@ +{{- $analytics := site.Params.analytics -}} + +{{- if $analytics.enable -}} + {{- /* Google Analytics */ -}} + {{- with $analytics.google.id -}} + {{- printf "https://www.googletagmanager.com/gtag/js?id=%v" . | dict "Async" true "Source" | partial "plugin/script.html" -}} + {{- end -}} + + {{- /* Fathom Analytics */ -}} + {{- with $analytics.fathom.id -}} + {{- dict "Source" ($analytics.fathom.server | default "cdn.usefathom.com" | printf "https://%v/tracker.js") "Async" true "Attr" "id=fathom-script" | partial "plugin/script.html" -}} + {{- end -}} + + {{- /* Baidu Analytics */ -}} + {{- with $analytics.baidu.id -}} + + {{- end -}} + + {{- /* Umami Analytics */ -}} + {{- with $analytics.umami.data_website_id -}} + + {{- end -}} + + {{- /* Plausible Analytics */ -}} + {{- with $analytics.plausible.data_domain -}} + + {{- end -}} + + {{- /* Cloudflare Analytics */ -}} + {{- with $analytics.cloudflare.token -}} + + {{- end -}} + + {{- /* Splitbee Analytics */ -}} + {{- if $analytics.splitbee.enable -}} + {{- $attr := "" -}} + {{- if $analytics.splitbee.Do_not_track -}} + {{- $attr = printf `%v data-respect-dnt` $attr -}} + {{- end -}} + {{- if $analytics.splitbee.No_cookie -}} + {{- $attr = printf `%v data-no-cookie` $attr -}} + {{- end -}} + {{- with $analytics.splitbee.data_token -}} + {{- $attr = printf `%v data-token="%v"` $attr . -}} + {{- end -}} + + {{- end -}} + +{{- end -}}