惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
The Register - Security
The Register - Security
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The GitHub Blog
The GitHub Blog
博客园 - 司徒正美
罗磊的独立博客
U
Unit 42
S
SegmentFault 最新的问题
Y
Y Combinator Blog
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
J
Java Code Geeks
Schneier on Security
Schneier on Security
Know Your Adversary
Know Your Adversary
C
Check Point Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
V
Vulnerabilities – Threatpost
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
The Hacker News
The Hacker News
博客园 - 叶小钗
C
Cybersecurity and Infrastructure Security Agency CISA
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Latest news
Latest news
L
Lohrmann on Cybersecurity
A
About on SuperTechFans
L
LangChain Blog
Stack Overflow Blog
Stack Overflow Blog
S
Securelist
A
Arctic Wolf
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Threatpost
Scott Helme
Scott Helme
博客园 - 聂微东
博客园 - 【当耐特】
T
Tenable Blog
I
Intezer
D
DataBreaches.Net
B
Blog RSS Feed
Security Latest
Security Latest
C
Cisco Blogs
T
Tor Project blog
N
Netflix TechBlog - Medium

Example blog

Ghost routing explained with routes.yaml examples — routes, collections & taxonomies Ghost redirects explained with practical redirects.yaml examples How to Serve JSON or XML Data in Ghost How to Change Your Default Post Template in Ghost Ghost Custom Theme Settings How to add Google Fonts to Ghost Themes How to Configure Ghost with Mailgun Ghost Theme Structure & Organization How to Make Custom Templates in Ghost Themes How to Install Ghost CMS via Ghost-CLI How to Add Syntax Highlighting to Ghost The best Ghost CMS hosting platforms Ghost 6.0 — Social Web and Native Ghost Analytics Ghost CMS Social web beta, email 2FA and more author social links How to keep custom design settings when updating your Ghost theme How to use the public preview card in Ghost How to add members-specific sections in Ghost How to customize the default content CTA in Ghost How to build a custom homepage in Ghost An overview of Ghost editor cards and and how they work Ghost CMS News: One-time payments & collecting sales tax How to customize the private site access template in Ghost How to add custom fonts in Ghost themes Ghost CMS News: Additional payment methods & internal linking How to use Code Injection in Ghost How to set meta data of your custom routes & collections in Ghost Ghost CMS News: TK reminders, ActivityPub and improvements How to format dates and use the date helper in Ghost Ghost CMS internationalization, custom fonts & spam protection Understanding and optimizing post and page settings in Ghost CMS Trigger the Ghost Portal popup based on page scroll progress How to Deploy Your Ghost Theme with GitHub Actions How to create a custom recommendations page for your Ghost CMS theme Ghost CMS News: New editor, refreshed settings & recommendations Ghost CMS News: Source - the new default theme and native image editing How to Add Different Logos for Dark & Light Themes in Ghost Upgrade to Node v18 for Ghost CMS & common errors Ghost Snippets: Adding Schema markup in Ghost How to add a scroll-based progress bar to your Ghost CMS site How to Create a Custom Navigation Template in Ghost How to Segment Subscribers with Member Labels in Ghost The best way to create a contact page in Ghost How to Use the Ghost Subscription Forms in Your Theme & Posts How to update your Ghost site URL when self-hosting Ghost CMS News: Signup cards and better landing pages How to Add Breadcrumbs to Your Ghost Theme How to integrate the Applause Button into your Ghost theme How to Hide a Post From the Home Page in Ghost CMS Ghost CMS block and contentFor helper overview & tips How to add Image Lightbox to Ghost Themes Ghost CMS News: Signup form embed, new editor and bulk actions. Biron Themes becomes Bright Themes 🎉 How to Audit & Test a Ghost Theme How to Create Related Posts Section in Ghost How to Use Ghost Filter Expressions Ghost CMS newsletter settings and post analytics How to Update Your Ghost Theme When We Release New Versions Ghost CMS News: Automatic list cleaning & email troubleshooting How to Create a Featured Post Slider in Ghost How to Add Reading Time to Ghost Blog Posts How to Create a Post Archive for Your Ghost Theme Ghost CMS Price Helper Overview & Tips Self-Hosted Ghost CMS with DigitalOcean Ghost CMS News: Member Growth Sources & Audience Feedback How to Open External Links in a New Tab in Ghost How to Integrate Google Analytics with Ghost Ghost CMS News: History Log & Newsletter Analytics How to Automatically Add Member Labels From Referral Traffic in Ghost? Ghost CMS News: Free trials & email notifications Ghost CMS Match Helper Usage & Tips Ghost CMS News: Native Comments Ghost CMS News: Ghost Explore & Premium Newsletter Previews Ghost Snippets: Custom Progress Cards & Steps Ghost CMS News: Native Search The Best Ghost CMS Search Plugins & Libraries Ghost Snippets: Custom Stylish Tables How to Add a Scroll Top & Progress Indicator Button in Ghost Ghost Snippets: Accordions How to Add Tag Dropdown to Your Ghost Theme Ghost 5.0 released 🎉 Ghost Snippets: Custom Subscribe Forms Ghost Snippets: Custom Alert Boxes How to Show Post or Newsletter Issue Number in Ghost Ghost CMS News: Membership, Tiers & Activity Feed Custom Pages in Ghost CMS Themes Ghost CMS Search Using Fuse.js Ghost CMS News: Offers and Discounts & New Cards Ghost CMS News: Membership tiers, email CTA & filters Ghost CMS News: Grammarly Support & Feature Image Captions. Ghost CMS News: Improved Member Accounts & Personalized Newsletter. Ghost 4.0 Launched With Native Newsletters & Membership Ghost CMS News: Cancellation Feedback & Newsletter Stats. Ghost CMS News: Improved Member Dashboard & Sidebar Views. Ghost CMS News: Google Pay support, email newsletters & secondary navigation Ghost CMS News: Member Support, Portal & Content Snippets. Ghost CMS News: Referral Programs & Responsive Images. Ghost Themes as Progressive Web Apps Ghost 3.0 is here with brand new features Ghost 2.0 is here with new features How to Add Search to Ghost Using ghostHunter
How to Self-Host Google Fonts in Ghost CMS
Bright Themes · 2022-03-20 · via Example blog

Google Fonts are widely used nowadays, many Ghost Themes have such fonts integrated by default and this can be an issue because Google Fonts is subject to GDPR regulations (General Data Protection Regulation).

A German court recently found that websites that have embedded Google Fonts violate GDPR because when a font is requested by the user’s browser, the user’s IP address is recorded by Google and used for analytical purposes.

To be GDPR compliant, you have several options:

  • stop using Google Fonts altogether
  • self-host the fonts

In the next part, we will focus on the second option and the steps you have to do, to use Google fonts in GDPR compliant manner (self-host) in your Ghost Theme.

  1. Remove google font requests
  2. Download the font files
  3. Generate the CSS rules
  4. Integrate the font files and CSS rules

Remove google font requests

Generally, to add google fonts you have to add the following code (example with the Inter font):

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap"
  rel="stylesheet"
/>

To avoid any outgoing requests towards the Google servers, you have to look for this code and remove it from your template. The most common place where this is placed is in the default.hbs file, but if it's not there, try searching within the theme directory for fonts.g

After you removed the <link> elements you can double-check in DevTools that there are no outgoing requests, by going to the Network tab and the Font section.

Download the font files

After the previous step is done, and your website doesn't have requests towards the google servers, you should see the fallback fonts loaded instead, which in most cases will be browser fonts.

If you still want to retain the same look and feel, you have to self-host the fonts. You have to download the font files and add them to your theme. Fonts can be downloaded following the steps below (or do it via google-webfonts-helper, see next chapter for more details)

  • Go to fonts.google.com
  • Search for the font family you want to download
  • Select the styles (font weights)
  • Finally, press Download all to get the zip file

After downloading, you have to place the font files in your Ghost theme. The ideal place would be in the assets/fonts directory, if the fonts directory doesn't exist you can create it.

When all this is done, you are ready to self-host the fonts.

Generate the CSS rules

When using custom fonts, you must define the @font-face rules, which specify a custom font with which to display text. The default Google fonts integration handles this automatically, but in case you want to self-host you have to do it yourself.

Luckily there is a handy tool (google-webfonts-helper) that generates these rules for us (see the github project). The process is done in several steps:

  1. Select charsets (default is latin)
  2. Select style (font weights)
  3. Copy CSS (modern browsers is enough in most cases)
  4. Download files (as mentioned previously the files have to be placed in the assets directory)

One important aspect is the option to change the directory prefix before generating the CSS rules.

Caution

For the fonts to work, it's important that the CSS rules have the correct path to the font files.

Integrate the font files and CSS rules

As already mentioned, the font files have to be placed within the theme (ideally in the assets/fonts directory). When this is done, the last step is adding the CSS.

CSS can be added either into a CSS file or directly using the Code Injection area available in Ghost Admin. Let's see an example.

Assuming we want to integrate the Inter font, after selecting the styles and downloading the font files, we have the following in the /assets/fonts directory:

  • inter-v8-lating-700.woff
  • inter-v8-lating-700.woff2
  • inter-v8-lating-800.woff
  • inter-v8-lating-800.woff2
  • inter-v8-lating-regular.woff
  • inter-v8-lating-regular.woff2

And the following CSS rules:

/* inter-regular - latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  src: local(''),
    url('/assets/fonts/inter-v8-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
      url('/assets/fonts/inter-v8-latin-regular.woff') format('woff');
  /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

/* inter-700 - latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  src: local(''), url('/assets/fonts/inter-v8-latin-700.woff2') format('woff2'),
    /* Chrome 26+, Opera 23+, Firefox 39+ */
      url('/assets/fonts/inter-v8-latin-700.woff') format('woff');
  /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

/* inter-800 - latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  src: local(''), url('/assets/fonts/inter-v8-latin-800.woff2') format('woff2'),
    /* Chrome 26+, Opera 23+, Firefox 39+ */
      url('/assets/fonts/inter-v8-latin-800.woff') format('woff');
  /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}

Warning

Note that the path to the font files /assets/fonts/ has to match where the font files actually are (if you placed the font files in the assets directory, the @font-face url needs that path)

Add the font rules, inside <style> tag in Code Injection. Now that this is done, the only thing remaining is making sure the website uses the correct font. This may vary based on how it is set in your theme, but adding the following rule in code injection should work:

body * {
  font-family: 'Inter';
}

That's it, you are now self-hosting google fonts within your Ghost theme.