Self-Hosting Fonts

While Google provides a free CDN for their web fonts, there are two reasons you might want to host them yourself instead…
It can be more performant. You don’t want Google tracking info on your site (in 2022, Germany ruled that fonts embedded from Google violate GDPR). Fortunately, self-hosting Google Fonts involves just three steps…
Download the font files. Upload them to your server. Load them on your site.


This content originally appeared on Go Make Things and was authored by Go Make Things

While Google provides a free CDN for their web fonts, there are two reasons you might want to host them yourself instead…

  1. It can be more performant.
  2. You don’t want Google tracking info on your site (in 2022, Germany ruled that fonts embedded from Google violate GDPR).

Fortunately, self-hosting Google Fonts involves just three steps…

  1. Download the font files.
  2. Upload them to your server.
  3. Load them on your site.

Let’s look at exactly how to do it!

1. Download the font files

First, you need to get the font files to self-host.

  1. Visit the Google Webfonts Helper.
  2. Search for your typeface.
  3. Select the character sets (ex. Latin, Cyrillic) and styles/weights (ex. italic, bold) that you want.
  4. Select your browser support option. I’d recommend “Modern Browsers.”
  5. Click the “Download” button to download your font files

2. Upload the fonts to your server

Once you have the files, you need to host them somewhere.

Upload them to your server the same way you would host your CSS or JS files. You might do this through an FTP client, a GUI (like the WordPress file uploader), or by pushing your codebase to GitHub.

Whatever your deployment process is, use it for the font files, too.

3. Load the font on your site

Once that’s done, you need to load them in your CSS.

With Google’s CDN, you would drop in a link to their CSS file. When self-hosting, you have to create that file yourself. Fortunately, the Webfonts Helper provides that code for you, too.

Here’s what the CSS file Merriweather in regular, italic, bold, and bold italic looks like…

/* merriweather-regular - latin */
@font-face {
	font-display: swap;
	font-family: 'Merriweather';
	font-style: normal;
	font-weight: 400;
	src: url('../fonts/merriweather-v30-latin-regular.woff2') format('woff2');
}

@font-face {
	font-display: swap;
	font-family: 'Merriweather';
	font-style: italic;
	font-weight: 400;
	src: url('../fonts/merriweather-v30-latin-italic.woff2') format('woff2');
}

/* merriweather-700 - latin */
@font-face {
	font-display: swap;
	font-family: 'Merriweather';
	font-style: normal;
	font-weight: 700;
	src: url('../fonts/merriweather-v30-latin-700.woff2') format('woff2');
}

/* merriweather-700italic - latin */
@font-face {
	font-display: swap;
	font-family: 'Merriweather';
	font-style: italic;
	font-weight: 700;
	src: url('../fonts/merriweather-v30-latin-700italic.woff2') format('woff2');
}

Copy/paste that into a CSS file (I call mine fonts.css), update the url() paths, and load it the same way you would any other CSS file on your site.

Don’t forget to also declare the font-family in your CSS…

body {
	font-family: "Merriweather", serif;
}

The Webfonts Helper also automatically adds the font-display: swap property for more performant font loading.

Like this? A Lean Web Club membership is the best way to support my work and help me create more free content.


This content originally appeared on Go Make Things and was authored by Go Make Things


Print Share Comment Cite Upload Translate Updates
APA

Go Make Things | Sciencx (2025-02-27T14:30:00+00:00) Self-Hosting Fonts. Retrieved from https://www.scien.cx/2025/02/27/self-hosting-fonts/

MLA
" » Self-Hosting Fonts." Go Make Things | Sciencx - Thursday February 27, 2025, https://www.scien.cx/2025/02/27/self-hosting-fonts/
HARVARD
Go Make Things | Sciencx Thursday February 27, 2025 » Self-Hosting Fonts., viewed ,<https://www.scien.cx/2025/02/27/self-hosting-fonts/>
VANCOUVER
Go Make Things | Sciencx - » Self-Hosting Fonts. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/27/self-hosting-fonts/
CHICAGO
" » Self-Hosting Fonts." Go Make Things | Sciencx - Accessed . https://www.scien.cx/2025/02/27/self-hosting-fonts/
IEEE
" » Self-Hosting Fonts." Go Make Things | Sciencx [Online]. Available: https://www.scien.cx/2025/02/27/self-hosting-fonts/. [Accessed: ]
rf:citation
» Self-Hosting Fonts | Go Make Things | Sciencx | https://www.scien.cx/2025/02/27/self-hosting-fonts/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.