While looking at different GitHub profile pages this morning, I came across a visitor counter on Tyler’s page. This piqued my interest and looked at how he was generating it. It was made possible through a service hosted on glitch.me. There is a GitHub repo that contains the source for this. At first, it seemed like a thing only for GitHub readme markdown but looking at the docs, I realized that I can embed that in simple webpages too.
So, I updated single.html in my Hugo theme to add the following code. Single.html is the template for the article content in Hugo.
With Hugo framework, this becomes relatively easy since the variables provided within the page context while building the static pages will help us build the necessary URL for tracking the visitors to the page. Depending on what static page generator framework you use, you may have to change the code above.Share on: