Skip to content

Conversation

@tsanie
Copy link

@tsanie tsanie commented Feb 28, 2025

This PR introduces umami analytics for articles and displays a pageview tag after the reading time, as shown below:
image

Users can enable it by putting these parameters in a configuration file such as hugo.yaml:

params:
  analytics:
    umami:
      enabled: true
      host: https://u.example.com # your umami service URL
      siteId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
      token: # not required, you can use the cloudflare worker proxy, see https://blahba.com/en/p/using-umami-with-cloudflare-worker/
      startAt: # Date constructor parameters, such as `1735689600000` or `2025-01-01`

You can get a token via POST /api/auth/login with data { "username": "<your user>", "password": "<password>" }.

If you are worried about leaking the token, you can wrap it with a Cloudflare Worker, see this article: https://blahba.com/en/p/using-umami-with-cloudflare-worker/

- Added conditional rendering for view count in article details based on `Site.Params.Analytics`.
- Updated Umami analytics script to use structured parameters and fixed script inclusion.
- Included Umami analytics script in the head section.
@tsanie tsanie changed the title **feat:** Add Umami analytics and view count to article details feat: Add Umami analytics and view count to article details Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant