Do you want to improve your WordPress site‘s speed and typography? Using custom fonts is a great way to make your site look professional. However, loading external fonts from services like Google Fonts can slow down your page load time.
The good news is that you can host fonts locally to enhance design while also speeding up your site. In this comprehensive guide, I‘ll show you two easy methods to host local fonts in WordPress.
Contents
Why You Should Host Fonts Locally
Here are three key reasons why self-hosting fonts is better for performance:
-
Faster load times – According to Google PageSpeed Insights, locally hosted resources load 50% faster than external requests. So hosting fonts on your server improves speed more than pulling them from a CDN.
-
Avoid GDPR issues – When using Google Fonts, Google records the IP addresses of visitors from the EU/UK, which violates GDPR privacy regulations. Hosting locally means you own the font files, avoiding privacy concerns.
-
Consistent reliability – If an external service goes down, any fonts hosted on it will be unavailable, breaking your site‘s appearance. Self-hosted fonts are always accessible.
Now let‘s look at two easy ways to start hosting fonts locally on your WordPress site.
Method 1: Using a Plugin (Recommended)
The simplest way to host Google Fonts or any font locally is by using a plugin like Optimize My Google Fonts.
Here‘s how to use it:
-
Install and activate the Optimize My Google Fonts plugin within your WordPress dashboard.
-
Go to Settings > Optimize Google Fonts and configure the options:
-
Leave Optimization Method as ‘Self-Host Fonts‘
-
Set Font-Display to ‘Swap (recommended)‘
-
Leave other settings at defaults
-
-
Click Save & Optimize. The plugin will automatically download and host locally any Google Font files used on your site.
That‘s all there is to it! This seamlessly replaces external fonts with local files. Based on my experience managing over 50 WordPress sites, this plugin is by far the easiest way to self-host fonts, especially for beginners.
Method 2: Manually Hosting Fonts
You can also host font files manually without needing a plugin. Here are the steps:
-
Download font files in web font formats like WOFF, WOFF2, TTF, OTF, etc. Popular sources include:
-
Convert to web fonts using Font Squirrel‘s Webfont Generator if needed.
-
Upload fonts to your WordPress site in a
/fonts/folder within your theme directory. -
In your theme‘s stylesheet, use
@font-faceto load each local font file from its relative URL. -
In your CSS, set specific selectors like
h1,h2, etc. to use your self-hosted fonts.
While this method works for any font files, it‘s more complex than using a dedicated plugin. I‘d only recommend manually hosting fonts if you need more customization than the plugin allows.
Improve Web Performance With Local Fonts
Hosting fonts on your own server can significantly speed up your WordPress site. According to WebPageTest, locally hosted fonts load over 50% faster. This optimization, along with caching and image compression, helps your pages load faster.
With just a few simple steps, you can host fonts locally to enhance your WordPress site‘s appearance without compromising speed. Your visitors will appreciate the fast loading times!
I hope this guide helps you learn how to easily self-host fonts in WordPress. Let me know if you have any other questions!
