Hugo Google Analytics 模块

谷歌分析是一项免费的网络分析服务,为搜索引擎优化(SEO)和营销目的提供统计数据和基本分析工具。

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

安装

导入模块

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

导入模板

1<head>
2  {{ partialCached "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 时,不追踪当前页。