DEV Community

Andy Stewart
Andy Stewart

Posted on

Lightweight Analytics for Jekyll: Why I Chose Hit Kounter Over Google Analytics

Privacy and Speed First
As I continue to polish my Jekyll blog on GitHub Pages, I realized I needed one more thing: View Counts. I wanted to know which topics resonate most with my readers, but I had two strict requirements:

No Google Analytics: I don't want my site to be blocked or slowed down by heavy tracking scripts (especially considering accessibility in different regions).

Minimalist Integration: It should be as "plug-and-play" as Jekyll itself.

After searching, I found Hit Kounter. It’s simple, fits perfectly with static sites, and just works.

How to Set It Up in 2 Minutes
1. The Header Injection
First, you need to include the Hit Kounter script in your HTML <head>. Usually, this goes into your_includes/head.htmlfile:

HTML
<script src="https://cdn.jsdelivr.net/npm/hit-kounter@0.1.0/dist/hit-kounter.js"></script>

2. Displaying Views on Post Pages
To show the view count for a specific article, just add this tag to your post template (e.g., _layouts/post.html):

HTML
<span data-hk-page="current"> - </span> Views

The current attribute automatically detects the current URL.

3. Displaying View Counts on the Homepage
If you want to show the traffic for each post on your homepage index, use this snippet in your index.html loop:

HTML
<span data-hk-page="{{ post.url | prepend: site.url | prepend: 'https:' }}"> - </span> Views

Pro Tip: Hit Kounter requires the absolute URL to track accurately. That’s why we use prepend: site.url and ensure https: is explicitly added. Without the full protocol, the counter won't trigger.

That’s All!
Just git push and your analytics are live. No complex dashboards, no privacy concerns, just a clean, simple number that tells you what your audience loves.

It’s another small step toward building the perfect minimalist writing environment.

What are you using to track your static site? Are you a fan of self-hosted analytics or do you prefer these "Zero-Config" tools? Let me know in the comments!

About the Author:
I am Yong Wang, a 20-year Linux veteran and former CTO of Deepin. I’m currently building Little Chinchilla, an AI Agent host designed for private-domain computing. Catch me on GitHub where I spend most of my time hacking Emacs.

Top comments (0)