Skip to content

Commit

Permalink
feat: Added Plausible Analytics (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodehat committed Jan 30, 2022
1 parent 3afe0de commit b84efff
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Anatole's aims to be minimalistic and sleek but still brings some great function
- Google Analytics (optional)
- Comments powered by Disqus, Commento or Utteranc.es (optional)
- SimpleAnalytics (optional)
- Plausible Analytics (optional)
- KaTex support (optional)
- Formspree Contact Form (optional)
- Twitter Cards support
Expand Down Expand Up @@ -406,6 +407,16 @@ enable = true
# customurl = "https://analytics.example.com"
```

### Plausible Analytics

To use Plausible Analytics, include the following section and change the domain to your site's domain. If you self-host Plausible, you can optionally specify the url of your own instance.

```toml
[params.plausibleAnalytics]
domain = "example.com"
# serverURL = "https://analytics.example.com"
```

### Google Site Verification

To use Google Site Verification, add the following line to the `[params]`:
Expand Down
4 changes: 4 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ reversepagetitle = true # When set to 'true', the Window Title will be reversed
# enable = true
# customurl = "https://analytics.example.com"

[plausibleAnalytics]
# domain = "example.com"
# serverURL = "https://analytics.example.com"

## Math settings
[math]
enable = false # options: true, false. Enable math support globally, default: false. You can always enable math on per page.
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/analytics/plausible.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script async defer data-domain="{{ .Site.Params.plausibleAnalytics.domain }}" src="{{ .Site.Params.plausibleAnalytics.serverURL | default "https://plausible.io" }}/js/plausible.js"></script>
3 changes: 3 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@

{{- end -}}

{{ if and hugo.IsProduction .Site.Params.plausibleAnalytics .Site.Params.plausibleAnalytics.domain }}
{{- partial "analytics/plausible" . -}}
{{ end }}

<!-- Twitter Cards -->
{{ template "_internal/twitter_cards.html" . }}
Expand Down

0 comments on commit b84efff

Please sign in to comment.