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...
Full article excerpt tap to expand
try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 3890210) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Andy Stewart Posted on Apr 28 Lightweight Analytics for Jekyll: Why I Chose Hit Kounter Over Google Analytics #jekyll #analytics #webdev #productivity 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/[email protected]/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) Subscribe Personal Trusted User Create template Templates let you quickly answer FAQs or store snippets for re-use. Submit Preview Dismiss Code of Conduct • Report abuse Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse
This excerpt is published under fair use for community discussion. Read the full article at DEV Community.