How count the page views of my Octopress blog?
Asked Answered
H

1

6

I would like to add a simple counter to my blog posts. That way, each blog post has its own counter and can display how many times the post was clicked.

How can I achieve that with Octopress? Any ideas?

Thanks in advance for any tips!

Headship answered 11/4, 2013 at 20:10 Comment(1)
jekyll sites are static. What you are suggesting requires dynamism.Julissa
E
8

The best way in my opinion would be to setup Google Analytics on your blog by placing the Analytics code at the bottom of your _layouts/default.html file.

It won't allow others to see how many visits you have had per post, but you personally will be able to view that data and lots more.

For others to see also, you can use a third-party API that uses JavaScript. The third-party service tracks pageviews for you and then provides you with a JavaScript snippet that you paste your sidebar or where ever you want the pageviews to show up. StatCounter is an example (didn't verify if it is a good service or not).

This is a common method of adding dynamic-ish features to static sites like those generated by Jekyll. Often people do this same technique to add comments to their blogs with Discus.

Elnoraelnore answered 19/4, 2013 at 2:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.