Replace Google fonts with self-hosted fonts #370
AlexanderZeilmann
started this conversation in
Show and tell
Replies: 2 comments 2 replies
-
Fontsource is a really nice approach! It's about as easy to integrate as Google fonts and is self-hosted. Will modify the default template to use this. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Replaced Google Fonts with the self-hosted version in v1.5.0. Thanks @AlexanderZeilmann! Information on the performance improvement is in the PR. A short guide on the rationale for the change and how to customize the font is also included in the blog. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Problem
This might be relevant to you if you are based in the European Union.
Google fonts is not GDPR compliant (General Data Protection Regulation by the EU) see here for a court case in german, tldr: the website owner had to pay 100€ to a user because Google Fonts was included without asking for permission.
Since asking the user for the permission to include a font is probably not a convenient idea, it is best to self-host the fonts.
Here is a short explanation of how this can be done. Maybe it is useful to someone.
The Solution
Use fontsource. It lets you install fonts like npm packages. Things you need to do:
pages/_document.js
npm install -save @fontsource/<font-name>
, repeat for all your fontspages/_app.js
:*.googleapis.com
andfonts.gstatic.com
from Content Security Policy.Variable fonts
Variable fonts can be imported using
and replacing
'Roboto Mono'
by'Roboto MonoVariable'
in yourtailwind.config.js
(or wherever you are setting the font).Note, that this change alone does not make your site GDPR compliant, but it is a good start.
Other Advantages
See here
Alternatives
Beta Was this translation helpful? Give feedback.
All reactions