divinerites / plausible-hugo Goto Github PK
View Code? Open in Web Editor NEWDead simple integration between plausible.io and gohugo.io
License: GNU General Public License v3.0
Dead simple integration between plausible.io and gohugo.io
License: GNU General Public License v3.0
At least that's what I was told.
I hope this won't be one:
I spent 1 hour on making it work. Obviously I don't know enough about hugo. I copied the 1 line script to head.html and it worked.
Why can´t I just do that instead of playing with modules?
Hi! Is it possible to add this as a module within a theme module? Could you please update the documentation with a how-to? It would really help people who are still wrapping their heads around the concept of modules. Thank you!
I've setup my blog using Cloudfront and S3. I ended up using the custom_js_domain
option to get this to work for my site, using a cloudfront function to rewrite the URL from index.js
to plausible.js
. We need a proxy_netlify
option that is better suited for AWS. Open to other ideas, I can submit a patch if there's a sense of how best to implement this.
Hello,
thanks for the awesome project!,
can you add the ability to customize the tracking script's name?
I use nginx rewrite to get past ad-blockers, and it would be useful if this component can support custom script names.
Either the code is wrong or the documentation is not clear and finally as the last option I need something stronger than coffee.
I am not using netlify so all things related to netlify does not qualify for my case. I am expecting to get the code to produce the following
<link rel="preconnect" href="https://myplausible.hosting.domain">
<script defer data-domain="example.com"
script-src="https://myplausible.hosting.domain"
connect-src="https://myplausible.hosting.domain"
src="https://myplausible.hosting.domain/js/plausible.js" ></script>
but I can't seem to get he script-src and connect-src printed in the plausible script with the following
{{- with .Site.Params.plausible -}}
{{ printf " script-src " | safeHTML }}{{- partial "plausible_csp.html" . }}
{{ printf " connect-src " | safeHTML }}{{- partial "plausible_csp.html" . }}
{{- partial "plausible_head.html" . -}}
{{- end -}}
What am I missing
Hello,
I deployed a hugo site using the zzo-theme:
https://github.com/zzossig/hugo-theme-zzo
I then decided to add plausible analytics by using plausible-hugo.
Adding plausible-hugo to an existing site adds analytics without negative impact.
Adding plausible-hugo to an existing site adds analytics but removes copyright notice.
I've managed to reproduce this by creating a fresh hugo site and adding both themes.
Snippet of config/_default/config.toml
baseURL = "http://example.org"
title = "Hugo Zzo Theme"
theme = "zzo"
#theme = ["zzo", "plausible-hugo"] # Add this theme to your already existing other themes
#[params.plausible]
# enable = true # Whether to enable plausible tracking
# domain = "example.com" # Plausible "domain" name/id in your dashboard
copyright = "©{year}, All Rights Reserved"
Snippet of config/_default/config.toml
:
baseURL = "http://example.org"
title = "Hugo Zzo Theme"
#theme = "zzo"
theme = ["zzo", "plausible-hugo"] # Add this theme to your already existing other themes
[params.plausible]
enable = true # Whether to enable plausible tracking
domain = "example.com" # Plausible "domain" name/id in your dashboard
copyright = "©{year}, All Rights Reserved"
Themes installed:
~/devel/zzo-theme-tshoot/plausible-hugo-zzo$ ll themes/
total 16
drwxrwxr-x 4 td td 4096 gru 13 09:34 ./
drwxrwxr-x 11 td td 4096 gru 13 09:47 ../
drwxrwxr-x 3 td td 4096 gru 13 09:34 plausible-hugo/
drwxrwxr-x 10 td td 4096 gru 13 09:27 zzo/
td@emerald:~/devel/zzo-theme-tshoot/plausible-hugo-zzo$
I can provide a gitlab repo with the code pushed, so you can see all my steps.
site.IsServer
needs to be replaced by hugo.IsServer
, but this new function works only starting with hugo v0.120.0
.
So it is too violent and too soon to do it now.
Hello,
I host my static site on Netlify. When doing branch previews, I use this as the build command:
hugo --buildFuture -b $DEPLOY_PRIME_URL
Netlify provides the value for DEPLOY_PRIME_URL
as my site baseURL. Is there any way I can use this value as the configured Plausible domain? I would like any preview hits not be added to my regular site statistics.
according to the documentation and the actual code provided by plausible the tracking script name is not anymore plausible
<script defer data-domain="yourdomain.com" src="https://plausible.io/js/script.js"></script>
This module is still using the old approach of using plausible.js which is problematic due to various blockers
I might be being a bit daft but is there a way of enabling proxying without any Netlify options. I use Render and the rewrites are done through the dashboard. Is there a way of easily setting an empty path that gets rewritten or would it require a fork to change behaviour?
The console message is issued for each site.Language.
We need to find a way to issue it only once
I’m trying to use the module approach with the congo
theme, but I don’t suppose this is limited solely to the this theme.
I’ve added {{ partial “plausible_head.html” . }}
to the layouts/partials/analytics.html
file which the congo theme uses to store all the analytics stuff that will be put into the header.
However I suspect the variable scope/context is causing an issue (error: <.Page.Kind>: can't evaluate field Page in type *hugolib.SiteInfo
), so I’m wondering if there is a more generic way to make this work using $.
to get the global context?
Full error message below.
$ hugo
Start building sites …
hugo v0.110.0-e32a493b7826d02763c3b79623952e625402b168+extended linux/amd64 BuildDate=2023-01-17T12:16:09Z VendorInfo=gohugoio
WARN 2023/02/23 11:40:46 *** Please, consider leaving a star on Github if you like this plausible-hugo module.
Remove this warning by adding 'gitstar = false' in your plausible config
ERROR 2023/02/23 11:40:46 render of "home" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:17:6": execute of template failed: template: index.html:17:6: executing "index.html" at <partial "head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/partials/head.html:109:5": execute of template failed: template: partials/head.html:109:5: executing "partials/head.html" at <partialCached "analytics.html" .Site>: error calling partialCached: "[..]/layouts/partials/analytics.html:1:3": execute of template failed: template: partials/analytics.html:1:3: executing "partials/analytics.html" at <partial "plausible_head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/divinerites/[email protected]/layouts/partials/plausible_head.html:76:19": execute of template failed: template: partials/plausible_head.html:76:19: executing "partials/plausible_head.html" at <.Page.Kind>: can't evaluate field Page in type *hugolib.SiteInfo
ERROR 2023/02/23 11:40:46 render of "section" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:17:6": execute of template failed: template: _default/list.html:17:6: executing "_default/list.html" at <partial "head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/partials/head.html:109:5": execute of template failed: template: partials/head.html:109:5: executing "partials/head.html" at <partialCached "analytics.html" .Site>: error calling partialCached: "[..]/layouts/partials/analytics.html:1:3": execute of template failed: template: partials/analytics.html:1:3: executing "partials/analytics.html" at <partial "plausible_head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/divinerites/[email protected]/layouts/partials/plausible_head.html:76:19": execute of template failed: template: partials/plausible_head.html:76:19: executing "partials/plausible_head.html" at <.Page.Kind>: can't evaluate field Page in type *hugolib.SiteInfo
ERROR 2023/02/23 11:40:46 render of "taxonomy" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:17:6": execute of template failed: template: _default/taxonomy.html:17:6: executing "_default/taxonomy.html" at <partial "head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/partials/head.html:109:5": execute of template failed: template: partials/head.html:109:5: executing "partials/head.html" at <partialCached "analytics.html" .Site>: error calling partialCached: "[..]/layouts/partials/analytics.html:1:3": execute of template failed: template: partials/analytics.html:1:3: executing "partials/analytics.html" at <partial "plausible_head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/divinerites/[email protected]/layouts/partials/plausible_head.html:76:19": execute of template failed: template: partials/plausible_head.html:76:19: executing "partials/plausible_head.html" at <.Page.Kind>: can't evaluate field Page in type *hugolib.SiteInfo
ERROR 2023/02/23 11:40:46 render of "taxonomy" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:17:6": execute of template failed: template: _default/taxonomy.html:17:6: executing "_default/taxonomy.html" at <partial "head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/partials/head.html:109:5": execute of template failed: template: partials/head.html:109:5: executing "partials/head.html" at <partialCached "analytics.html" .Site>: error calling partialCached: "[..]/layouts/partials/analytics.html:1:3": execute of template failed: template: partials/analytics.html:1:3: executing "partials/analytics.html" at <partial "plausible_head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/divinerites/[email protected]/layouts/partials/plausible_head.html:76:19": execute of template failed: template: partials/plausible_head.html:76:19: executing "partials/plausible_head.html" at <.Page.Kind>: can't evaluate field Page in type *hugolib.SiteInfo
Error: Error building site: failed to render pages: render of "page" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/_default/baseof.html:17:6": execute of template failed: template: _default/single.html:17:6: executing "_default/single.html" at <partial "head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/jpanther/congo/[email protected]/layouts/partials/head.html:109:5": execute of template failed: template: partials/head.html:109:5: executing "partials/head.html" at <partialCached "analytics.html" .Site>: error calling partialCached: "[..]/layouts/partials/analytics.html:1:3": execute of template failed: template: partials/analytics.html:1:3: executing "partials/analytics.html" at <partial "plausible_head.html" .>: error calling partial: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/divinerites/[email protected]/layouts/partials/plausible_head.html:76:19": execute of template failed: template: partials/plausible_head.html:76:19: executing "partials/plausible_head.html" at <.Page.Kind>: can't evaluate field Page in type *hugolib.SiteInfo
Total in 170 ms
sorry, fat fingers hit create issue too quickly.
Hello,
I've got a website using the WowChemy Academic Resume theme, and I'm on the latest version and things seem to be done slightly differently, so I'd love some help about Step 3 of the three easy steps in the README file:
- Call the partial plausible_head.html in your own section.
My question is how/where do I actually do this?
I am using a config.yml file and I'd like to install it using the plausible-hugo module way. I've done it like so:
module:
imports:
- path: github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-netlify-cms
- path: github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy-plugin-netlify
- path: github.com/wowchemy/wowchemy-hugo-themes/modules/wowchemy/v5
- path: github.com/divinerites/plausible-hugo
Then, I created a new file called head.html
in partials/
like so and added the snippet as suggested (I also tried extra_head.html):
<head>
...
{{ partial "plausible_head.html" . }}
...
</head>
Is this the right thing to do ? Should this now work? Unfortunately I don't see the plausible.io js in my source when I try to look at the source of the website, nor has the site picked up any traffic.
Here is my directory structure (you'll notice there is no themes directory).
P.S. I'd be happy to contribute some additional instructions back as a PR if I can get this to work. Thanks in advance for your work on this!
We need to adapt plausible_redirect_netlify.html
to be coherent if site.Params.plausible.file_downloads
is set.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.