Site logo

[Support request] Regarding hosting Google fonts locally

Home Forums Support [Support request] Regarding hosting Google fonts locally

Home Forums Support Regarding hosting Google fonts locally

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1565589
    Chitika

    I would like to host the Google fonts I’m using for my site locally on my server.
    In page speed tests, I see that loading these fonts externally is causing some increase in page load time.
    Can you tell me how to implement it with GP.

    #1565592
    Elvin
    Staff
    Customer Support

    Hi,

    You can check this brief documentation on how to add local fonts to your site.
    https://docs.generatepress.com/article/adding-local-fonts/

    #1566846
    Chitika

    Hi,
    I have added a font – “Source Sans Pro” on my site for the body section as you said.
    Now, in the Typography setting, I have selected it as system font.

    In the Font Family section, I see 200, 200 italic, etc. kind of items.
    Are they all required to be included. Or else I can delete them.

    #1566867
    Elvin
    Staff
    Customer Support

    In the Font Family section, I see 200, 200 italic, etc. kind of items.
    Are they all required to be included. Or else I can delete them.

    You can remove them if you don’t need them. 🙂

    #1566879
    Chitika

    Few questions.

    In the Font Family section, I see 200, 200 italic, etc. kind of items.
    Are they all required to be included. Or else I can delete them.

    You can remove them if you don’t need them. 🙂

    1. If I delete them, can i get all of them back easily or do I need to add them individually.
    2. Also, since I don’t need the Google Fonts now, how to disable them.
    3. From personal experience, do you think hosting Google fonts locally is a good idea.

    #1566894
    Baz

    Hi Chitika,

    I recently read this article by WP Rocket: https://wp-rocket.me/blog/self-hosting-google-fonts/

    From the article, it seems to suggest there is negligible difference in hosting fonts locally vs linking to google fonts.

    Don’t know if the GP team would agree with that 🙂

    #1566959
    Elvin
    Staff
    Customer Support

    From the article, it seems to suggest there is negligible difference in hosting fonts locally vs linking to google fonts.

    “Neglible” is relative to how nitpicky a person is. Some people are bothered by the 0.02 second difference. lol.

    Kidding aside, that’s actually true in some cases where the font query is well specified. But there are also sites where locally hosting fonts cuts the loading time by half as google font’s render-blocking CSS can be an issue. And this is related to CLS issues reported by Google PSI on some sites.

    #1566964
    Baz

    Ha ha, 0.02 seconds improvement is the holy grail for some people lol.

    I myself prefer to use the most popular google fonts (e.g. Roboto), as there is a distinct possibility that your visitor’s browser has already cached that font from surfing other websites.

    If you’re going to use one of the more fancier fonts, then hosting locally would be beneficial.

    Thanks Elvin.

    #1573713
    Shuhui

    Hi all,
    sorry to jump in this conversation. I was also looking to host my fonts, but, following your article, when uploading the fonts to the Media Library (after adding the php code), the .tff files still cannot be uploaded “for security reasons”. All the other files type are uploaded without a problem.
    Is this an error you can reproduce? Or have an idea what could be causing it?
    Thanks a lot

    #1573752
    Elvin
    Staff
    Customer Support

    Hi all,
    sorry to jump in this conversation. I was also looking to host my fonts, but, following your article, when uploading the fonts to the Media Library (after adding the php code), the .tff files still cannot be uploaded “for security reasons”. All the other files type are uploaded without a problem.
    Is this an error you can reproduce? Or have an idea what could be causing it?
    Thanks a lot

    Hi @Clemence,

    If WordPress doesn’t .tff file uploads, you’ll have to add in a snippet that allows it.

    Example:

    add_filter('upload_mimes', 'add_custom_upload_mimes');
        function add_custom_upload_mimes($existing_mimes) {
            $existing_mimes['ttf'] = 'application/x-font-ttf';
            return $existing_mimes;
    }
    #1573758
    Shuhui

    Hi Elvin,

    Thanks for your fast reply. What I am saying is, even with the php snippet (the one you gave me here or the one we can find in the GP article), it still doesn’t work. On my side at least.

    #1575004
    Elvin
    Staff
    Customer Support

    Hi,

    Can you try checking your file here for it’s mime type?
    https://wp-check-mime-type.com/

    It also provides the snippet when you check.

    If it still has issues, can you link us to the .ttf file? To test on other servers if it works.

    Let us know.

    #1575333
    Shuhui

    Yup still doesn’t work 🙁
    I downloaded the files for Montserrat from this website, for regular, italic, 700 and 700 italic.

    Cheers

    #1575353
    Elvin
    Staff
    Customer Support

    Strange.

    If you have access to FTP, you can edit your site’s wp-config.php and set this:

    define('ALLOW_UNFILTERED_UPLOADS', true);

    This allows ALL files to be uploaded. After setting this, you should be able to upload your .TTF or any file.

    Note: It is not recommended to keep this setting open as it exposes your site to potential threats. After uploading your file, make sure to disable this again.

    Alternatively, try using plugins that lets you upload your font files.

    #1575357
    Shuhui

    Sadly I don’t have access to FTP. Thanks for your help!

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.