Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
//app/root.tsx
export function links() { return [ { rel: 'preconnect', href: 'http://fonts.googleapis.com', referrerPolicy: 'origin', }, { rel: 'preconnect', href: 'http://fonts.gstatic.com', crossOrigin: 'anonymous', referrerPolicy: 'origin', }, { rel: 'stylesheet', href: 'http://fonts.googleapis.com/css2?family=Quicksand:wght@300..700&display=swap', crossOrigin: 'anonymous', referrerPolicy: 'origin', }, {rel: 'stylesheet', href: tailwindCss}, {rel: 'stylesheet', href: resetStyles}, {rel: 'stylesheet', href: appStyles}, { rel: 'preconnect', href: 'https://cdn.shopify.com', }, { rel: 'preconnect', href: 'https://shop.app', }, {rel: 'icon', type: 'image/svg+xml', href: favicon}, ]; }
I am trying to fetch google fonts, where I add the google fonts links to function links() and set the Referral Policy to origin, but I am still having trouble fetching the google fonts.
Solved! Go to the solution
This is an accepted solution.
Hi @princessfiona,
To implement Google Fonts in Shopify Hydrogen, ensure your Content Security Policy (CSP) includes fonts.googleapis.com and fonts.gstatic.com in fontSrc and styleSrc directives. This resolves blocked requests caused by restrictive CSP settings. You can update your CSP using the createContentSecurityPolicy utility. Check Shopify’s documentation for details: CSP Guide.
Alternatively, for better performance and to avoid CSP updates, consider using the Fontsource library to self-host fonts. It eliminates the need to fetch fonts externally and improves load times. See an example in the Pilot Theme.
This is an accepted solution.
Hi @princessfiona,
To implement Google Fonts in Shopify Hydrogen, ensure your Content Security Policy (CSP) includes fonts.googleapis.com and fonts.gstatic.com in fontSrc and styleSrc directives. This resolves blocked requests caused by restrictive CSP settings. You can update your CSP using the createContentSecurityPolicy utility. Check Shopify’s documentation for details: CSP Guide.
Alternatively, for better performance and to avoid CSP updates, consider using the Fontsource library to self-host fonts. It eliminates the need to fetch fonts externally and improves load times. See an example in the Pilot Theme.
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025