Is it possible to remove google infestation from my Hugo site?

Providing uMatrix output to see what i mean:

I’m using custom fonts.
Just want to simplify website for unneeded requests to third parties.

Any ideas on this?

Link to website

  1. Self-host your fonts rather than get them from Google:
    Good stuff without Google | BryceWray.com

  2. Use an analytics provider other than Google Analytics. I recommend Fathom Analytics*, but some prefer Plausible Analytics.

* Full disclosure: that’s an affiliate link. If you sign up with Fathom after doing the free trial by using that link, you’ll get a discount and I’ll receive a small commission.

Thanks for answer. I’m not using google fonts, custom fonts are loading from my website.
And i don’t need any analytics whatsoever.

1 Like

I based the note about fonts from your graphic. But, to be sure, this comes from the source code of your link:

<link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700">

… and from the browser’s Network tab checking for fonts:

https://fonts.gstatic.com/s/opensans/v34/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTS-mu0SC55I.woff2

:person_shrugging:

2 Likes

Aha, i get it. Thank you so much!
There are unneeded requests in css file regarding fonts and analytics.
But i need to investigate more, i don’t think that this will be so easy to solve.

1 Like

Removed lines:

{{- $googleFontsLink := .Site.Params.googleFontsLink | default "https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700" }}
	{{- if hasPrefix $googleFontsLink "https://fonts.googleapis.com/" }}
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
	<link rel="dns-prefetch" href="//fonts.googleapis.com">
	<link rel="dns-prefetch" href="//fonts.gstatic.com">
	<link rel="stylesheet" {{ printf `href="%s"` $googleFontsLink | safeHTMLAttr }}>
	{{- end }}

AND

{{- if not .Site.IsServer }}
		{{- if hasPrefix .Site.GoogleAnalytics "G-" }}
		{{ template "_internal/google_analytics.html" . }}
		{{- else }}
		{{ template "_internal/google_analytics_async.html" . }}
		{{- end }}
	{{- end }}

But still getting doubleclick.net requests, google analytics, gstatic and gfonts on pages with youtube videos, where {{<youtube >}} code is used. On plain pages with text and images requests disappeared.

It looks like there is no easy way to get rid of that…

Do you have this in your site configuration?

[privacy.youtube]
privacyEnhanced = true

https://gohugo.io/about/hugo-and-gdpr/#all-privacy-settings

2 Likes

Ohaaa, that was super helpful!
Thanks for pointing out. Strange thing that i didn’t find it by myself [lazy bastard].

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.