Hugo 輕量級 Google Analytics 模塊

輕量級谷歌分析記錄頁面瀏覽量、網站搜索、滾動和文件下載,而無需加載官方笨重的跟蹤庫。

Modulegithub.com/hugomods/minimal-google-analytics
StatsGitHub Stars Used By Used By Used By Used By

安裝

導入模塊

1module:
2  imports:
3  - path: github.com/hugomods/minimal-google-analytics
1[module]
2  [[module.imports]]
3    path = 'github.com/hugomods/minimal-google-analytics'
1{
2   "module": {
3      "imports": [
4         {
5            "path": "github.com/hugomods/minimal-google-analytics"
6         }
7      ]
8   }
9}

導入模板

1<head>
2  {{ partialCached "hugomods/minimal-google-analytics/index" . .Params.analyze }}
3</head>

站點配置

services.googleAnalytics.ID

名稱上下文類型必填默認值版本示例
services.googleAnalytics.ID-string---G-XXXXXXXX

衡量 ID。

站點配置示例

hugo.yaml

1services:
2  googleAnalytics:
3    ID: G-XXXXXXXXXX

hugo.toml

1[services]
2  [services.googleAnalytics]
3    ID = 'G-XXXXXXXXXX'

hugo.json

1{
2   "services": {
3      "googleAnalytics": {
4         "ID": "G-XXXXXXXXXX"
5      }
6   }
7}

頁面參數

analyze

名稱上下文類型必填默認值版本示例
analyze-boolean-true--

false 時,不追蹤當前頁。