How to Add Google Web Fonts in WordPress Themes the “Right” way – WPSaviour

By WP Saviour •  Updated: 02/27/21 •  5 min read

Google fonts are wonderful free useful resource for internet designers. In WPBv4, now we have began utilizing a preferred Google Font mixture: Oswald and Lora. A few of our customers have requested us tips on how to add Google Internet fonts in WordPress themes. In the event you keep in mind, we confirmed tips on how to add Google fonts in WordPress Put up Editor. On this article, we’ll present you tips on how to add Google Internet Fonts in your WordPress themes the RIGHT manner, optimized for efficiency.

Discover the Google Internet Fonts that You Like

Very first thing you could do is discover a Google font that you just like. Head on over to Google fonts and flick through the library. Whenever you discover the font that you just like, click on on the “Fast-use” button.


When you click on the quick-use button, you can be taken to a brand new web page. Scroll down until you see the utilization instruction field with code you can add to your web site.


You will note that there are three completely different tabs for including the font to your website. The primary one is the usual and really useful methodology so as to add Google fonts to your website. The second tab makes use of the @import CSS methodology, and the final tab makes use of the JavaScript methodology.

We are going to present you tips on how to use every of those strategies and what are there execs and cons.

Video Tutorial

Subscribe to WPBeginner

In the event you don’t just like the video or want extra directions, then proceed studying.

Including Google Internet Fonts in WordPress Themes

We’ve principally seen people utilizing the primary two strategies.

The simplest manner can be to open your theme’s fashion.css file and paste the fonts code that you just bought within the @import tab, like this:



@import url(;

@import url(;

You too can mix a number of font requests into one. Right here is how you’ll do it:


@import url(|Oswald);

This methodology is tremendous simple however it’s not one of the simplest ways add Google fonts to your WordPress website. Utilizing @import methodology blocks parallel downloads, which suggests the browser will look forward to the imported file to complete downloading earlier than it begins downloading the remainder of the content material.

In the event you MUST use @import, then no less than mix a number of requests into one.

Efficiency Optimized Methodology of Including Google Internet Fonts

The easiest way of including Google fonts is through the use of the Customary methodology which makes use of the hyperlink methodology as an alternative of the import methodology. Merely take your font URL that you just bought from step 1. In case you are including a number of fonts, then you may mix the 2 fonts with a | character. Then place the code in your theme’s head part.

You’ll most probably should edit your header.php file, and paste the next code above your major stylesheet. The instance would appear to be this:



Mainly the objective is to place the font request as early as doable. Based on the Google Web Fonts blog, if there’s a script tag earlier than the @font-face declaration, then Web Explorer received’t render something on the web page till the font file is finished downloading.

After you have executed that, you may merely begin utilizing it in your theme’s CSS file like this:




h1 {

    font-family: 'Oswald', Helvetica, Arial, serif;


Now there are loads of theme frameworks and youngster themes on the market. It’s NOT really useful to change your mother or father theme’s recordsdata specifically in case you are utilizing a theme framework as a result of your modifications can be overridden the subsequent time you replace that framework. You’ll need to make the most of the hooks and filters offered to you by that mother or father theme or framework so as to add Google fonts correctly in your youngster themes.

Correctly Enqueuing Google Fonts in WordPress

One other manner so as to add Google fonts to your WordPress website is by enqueuing the font in your theme’s capabilities.php file or a website particular plugin.







operate wpb_add_google_fonts() {

wp_enqueue_style( 'wpb-google-fonts', ',400italic,700italic,400,700,300', false );


add_action( 'wp_enqueue_scripts', 'wpb_add_google_fonts' );

Don’t neglect to switch the font hyperlink with your personal.

Loading Google Fonts Utilizing JavaScript

For this methodology you will have to repeat the code within the JavaScript tab in Google fonts utilization directions part. You’ll be able to paste this code in your theme or youngster theme’s header.php file instantly after tag.

Our final tip on utilizing Google Internet Fonts in your website can be to don’t load fonts you received’t use. For instance, when you solely need the daring, and regular weight, then don’t add all the opposite kinds.

We hope that this text helped you add Google Internet Fonts in your WordPress themes the best manner, so your website can load quick. You might also wish to try our information on how to add Typekit fonts in WordPress.

gp-8351008 as-2721382

WP Saviour

I am a WordPress specialist. My mission is to help you create beautiful websites with ease!