How to remove Google Fonts from the Twenty Seventeen theme

WordPress uses Google Fonts to provide Libre Franklin a versatile sans serif font in the Twenty Seventeen theme.

However, There are practical reasons not to rely on third party font hosting.

WordPress uses Google Fonts to provide Libre Franklin a versatile sans serif font in the Twenty Seventeen theme.

However, There are practical reasons not to rely on third party font hosting. Local development while disconnected from the internet, privacy concerns, unreliable access to Google services, or perhaps you just want to minimize your reliance on a third-party resources whenever possible.

In this post I’ll show you how to remove Google Fonts from the Twenty Seventeen theme and replace it with a locally hosted version. Libre Franklin is licensed under the SIL Open Font License and self hosting is permitted.

To begin I suggest installing Privacy Badger or another browser plugin that will allow you to easily see what third party services are connected to your website.

Precautions

This sort of development can easily break your website. Do not attempt to do this in a live production environment. I strongly suggest using Desktop Server or a local testing environment.

Lets Get Started

You may want to disable Avatar Display in Settings > Discussion to remove Gravitar support so it doesn’t appear in Privacy Badger as a possible tracker.

Create a Child Theme

It’s good practice to Create a Child Theme whenever making customizations to an existing theme. If you haven’t done this before read up on the process before proceeding.

Our child theme will require only two files. style.css and functions.php everything else will be inherited from Twenty Seventeen.

style.css
An example of my Twenty Seventeen Child theme style.css

Now create an empty functions.php file. We’ll be doing all our work in that file.

<?php
add_action( 'wp_enqueue_scripts', 'twentyseventeen_child_enqueue_styles' );
function twentyseventeen_child_enqueue_styles() {
        wp_enqueue_style( 'twentyseventeen-style', get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'twentyseventeen-child-style', get_stylesheet_directory_uri() . '/style.css' );
}
/* Remove Google Fonts from being imported from Google:
 * This will remove Franklin Libre and any other Google fonts
 * imported from the partent theme.
 * https://codex.wordpress.org/Function_Reference/wp_dequeue_style
 * */

add_action( 'wp_print_styles', 'remove_google_fonts', 1);
function remove_google_fonts() {
   wp_dequeue_style( 'twentyseventeen-fonts' );
}
/* A child theme's functions.php runs before the parent.
 * To remove a filter you have to run it later during init
 * */
function remove_google_fonts_preconnect() {
    remove_filter('wp_resource_hints', 'twentyseventeen_resource_hints');
}
add_filter('init', 'remove_google_fonts_preconnect');


/* Disable prefetch of Google Fonts API and s.w.org
 * https://wordpress.org/support/topic/remove-the-new-dns-prefetch-code/
 * https://developer.wordpress.org/reference/functions/wp_resource_hints/
 * Remove broken call to Google API
 * Remove call to WordPress.org for Emoji support
 * Remove it one step after the fonts '2'
 * */
remove_action( 'wp_head', 'wp_resource_hints', 2 );

/* Remove Parent Theme's editor style that imports the Google Fonts API
 * */
add_action( 'admin_init', 'my_remove_parent_styles' );
function my_remove_parent_styles() {
        remove_editor_styles();
?>
  1. un-click Avatar Display in Settings > Discussion
  2. Create a child theme
    1. In functions.php do the following
    2. dequeue google fonts or any other tracking scripts.
      1. https://codex.wordpress.org/Function_Reference/remove_action
    3. Remove Google Fonts Preconnect filter as it’s no longer needed
    4. use init so it runs after the parent theme scripts load
    5. Remove prefetch of google fonts and WordPress.org
    6. Remove post editor styles that also pull in google fonts
      1. https://core.trac.wordpress.org/ticket/36778?cversion=0#trac-change-9-1488153907292022

Notes

Not all fonts permit self hosting in their license agreement, please refer to your license agreement before substituting your favorite typeface.

How I’m replacing Instagram with WordPress

By using the official WordPress App I can create an Instagram like experience without Instagram.

I set forth a challenge to remove Facebook and its properties from my online presence and this includes Instagram.

Here I’m using the official WordPress App from Automattic and Snapseed by Google along with the Twenty Sixteen theme on my website to get the job done. What follows is a step back step gallery with screenshots. Yes, its more steps than Instagram but all the features are there.

Open the WordPress app
First, I open the WordPress app and click the circular button at the bottom right to create a new post.

upload the photos from my phone
Next, I upload the photos from my phone.

That’s basically it. However, if I’m willing to put in the additional effort. I’ll open up Snapseed to edit the image before uploading. This allows me to use automatic image editing filters and reduce the file size if I want to conserve my data during the upload process.

A photo I took at the Petersen Automotive Museum recently
A photo I took at the Petersen Automotive Museum recently

I open the image in Snapseed and prepare a smaller standard HD copy for export and upload.
I open the image in Snapseed I open the image in Snapseed and prepare a smaller standard HD copy for export and upload.

Additional image filters in Snapseed
I’d be negligent if I didn’t mention the Instagram like filters available in Snapseed

Back on the WordPress app there are additional settings found by tapping the gear icon. Here, I set the featured image, Geo location, as well as organize the post with categories, tags and custom post types.

Post Types
The Twenty Sixteen theme offers additional post types to further organize your post by type.

Geo tagging the post
Use your phones location to Geo tag the post

Confirm the location
Confirm the location.

Review details of your post
Review every detail of what you’re sharing.

File details screen
Set a display size, caption, alt text and even link the image.

That’s a lot of steps. However I can choose every detail or skip anything I don’t need for that particular post. This allows me to share as little detail or as much as I’d like.

The important point to take away is that there are options beyond closed social media platforms to share photos. Sure, I use Snapseed here to make adjustments but I can easily leave that out.