lukeorth / poison

Professional Hugo theme for dev bloggers. Based on Mdo's classic Hyde theme.
https://poison.lukeorth.com
GNU General Public License v3.0
198 stars 98 forks source link

Adding support for Plausible integration #113

Closed JonAugust closed 1 year ago

JonAugust commented 1 year ago

The self-hosted version of Plausible is a great alternative to Google Analytics. Once you have Plausible set up, tracking your site traffic is as simple as adding something like this to the <head> of each page:

<script defer data-domain="myblog.com" src="https://plausible.myblog.com/js/script.js"></script>

where "myblog.com" is the domain for your blog, and "plausible.myblog.com" is the FQDN or hostname for your plausible installation. My proposal is to update the scripts.html file in layouts/partials/head/ so that you can optionally add support for Plausible.

Your sitewide config.toml would have this configuration to add support for plausible:

[params]
    plausible = true
    plausible_domain = "myblog.com"
    plausible_script = "https://plausible.myblog.com/js/script.js"

I am certainly not fully aware of Hugo best practices, so please feel free to reject, adjust, or provide candid feedback. Thank you!

lukeorth commented 1 year ago

Thank you for the contribution, @JonAugust -- this looks great!

Have you been able to test these changes on your end? If so, I'll merge it. (I don't have Plausible yet, otherwise I'd verify it too.)

Plausible seems like a really neat project, so I may end up giving it a try and hosting my own instance. Good stuff!

JonAugust commented 1 year ago

Yep - I have this running on my blog with my local branch of poison. You can take a look here: [ REDACTED ]

[ REDACTED ]

lukeorth commented 1 year ago

Very nice -- thanks again!

JonAugust commented 1 year ago

Awesome. Thank YOU!