Giter Site home page Giter Site logo

plausible-hugo's People

Contributors

coliff avatar divinerites avatar marcbull avatar perryao avatar realorangeone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plausible-hugo's Issues

Custom tracking script name

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.

Alternative proxy options

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?

There is no stupid questions

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?

Error using module installation with “congo” theme

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

Including plausible-hugo as part of a theme

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!

Add better proxy request support for AWS Cloudfront hosted sites

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.

Adding plausible-hugo to zzo-theme breaks the copyright notice in the footer

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.

expected result

Adding plausible-hugo to an existing site adds analytics without negative impact.

actual result

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 = "&copy;{year}, All Rights Reserved"

Result:
image

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 = "&copy;{year}, All Rights Reserved"

Result:
image

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.

Use baseURL as configured Plausible domain?

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.

How does plausible_head_csp suppose to work

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

Confused about Step 3 of instructions: "<head>" section

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:

  1. 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).
Screen Shot 2022-08-15 at 9 31 52 PM

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!

Manage deprecated site.IsServer

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.