Hugo Plausible Analytics 模塊

Plausible 是一個輕量和開源的 Google Analytics 替代方案。

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

安裝

導入模塊

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

導入模板

1{{ partial "plausible-analytics/assets/js" . }}

站點配置

params.plausible_analytics.endpoint

名稱上下文類型必填默認值版本示例
params.plausible_analytics.endpoint-string-https://plausible.io--

Plausible Analytics 服務 URL。

params.plausible_analytics.file_downloads

名稱上下文類型必填默認值版本示例
params.plausible_analytics.file_downloads-boolean-false--

Whether to track file downloads.

名稱上下文類型必填默認值版本示例
params.plausible_analytics.outbound_links-boolean-false--

Whether to track clicks on outbound links.

params.plausible_analytics.local

名稱上下文類型必填默認值版本示例
params.plausible_analytics.local-boolean-false--

When true, track on localhost.

站點配置示例

hugo.yaml

1params:
2  plausible_analytics:
3    endpoint: https://plausible.io
4    file_downloads: false
5    local: false
6    outbound_links: false

hugo.toml

1[params]
2  [params.plausible_analytics]
3    endpoint = 'https://plausible.io'
4    file_downloads = false
5    local = false
6    outbound_links = false

hugo.json

 1{
 2   "params": {
 3      "plausible_analytics": {
 4         "endpoint": "https://plausible.io",
 5         "file_downloads": false,
 6         "local": false,
 7         "outbound_links": false
 8      }
 9   }
10}

頁面參數配置

analyze

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

false 時,不追蹤當前頁。

plausible_analytics.file_downloads

名稱上下文類型必填默認值版本示例
plausible_analytics.file_downloads-boolean----

Whether to track file downloads.

名稱上下文類型必填默認值版本示例
plausible_analytics.outbound_links-boolean----

Whether to track clicks on outbound links.

頁面參數示例

1analyze: true
2plausible_analytics:
3  file_downloads: false
4  outbound_links: false
1analyze = true
2[plausible_analytics]
3  file_downloads = false
4  outbound_links = false
1{
2   "analyze": true,
3   "plausible_analytics": {
4      "file_downloads": false,
5      "outbound_links": false
6   }
7}