Hi there,
My font looks great on desktop and on my shopify preview on my laptop but when i use a different device such as my phone, the font doesn’t load. Would anyone be able to help me? Thank you.
PW: ellaella
A custom font (RetroPodcast) displays correctly on desktop and Shopify preview but fails to load on mobile devices.
Root Cause:
Shopify doesn’t process Liquid template code in .CSS asset files, so the @font-face declaration with {{ "RetroPodcast.woff2" | asset_url }} isn’t being rendered properly. The font appears on the developer’s laptop because it’s either locally installed or browser-cached.
Recommended Solution:
@font-face code from assets/base.css@font-face code wrapped in <style> tags into this sectionAlternative Fix:
If the above doesn’t resolve the issue, upload font files to the Files section instead of Assets, and replace asset_url with file_url in the code. This addresses potential issues with Shopify breaking font files stored in Assets.
The discussion remains open pending confirmation whether the solution worked.
Hi there,
My font looks great on desktop and on my shopify preview on my laptop but when i use a different device such as my phone, the font doesn’t load. Would anyone be able to help me? Thank you.
PW: ellaella
This usually means that your font is not properly served to your visitors.
You see it on your laptop because it’s either installed there or cached in browser after you’ve researched this font…
You have this in your assets/base.css:
@font-face {
font-family: 'RetroPodcast';
src: url('{{ "RetroPodcast.woff2" | asset_url }}') format('woff2'),
url('{{ "RetroPodcast.woff" | asset_url }}') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
However, Shopify does not process Liquid in your .CSS assets.
You can try this instead – go to Customize and add a “Custom liquid” section to the Footer Group.
Paste this code to the “Custom liquid” input like this (and remove from base.css):
<style>
@font-face {
font-family: 'RetroPodcast';
src: url('{{ "RetroPodcast.woff2" | asset_url }}') format('woff2'),
url('{{ "RetroPodcast.woff" | asset_url }}') format('woff');
font-weight: normal;
font-style: normal;
font-display: swap;
}
</style>
And that would be the first step, because Shopify may break font files loaded to Assets.
If still does not work, upload your font files to Files and replace asset_url with file_url in the code above.
Thanks for that Tim - I just want to clarify though, what do you mean add it to the footer group? you mean add to bottom of footer.liquid? Or create my own custom.liquid in sections?
Yes, like this –
That’s in my opinion, better than adding code “above </body>” via theme code edit, but very much the same in terms of performance and effect.
Some of the huge benefits are:
Thats great - Let me give that a go. Thanks Tim.
working! had to replace asset_url with file_url
Can see it working too!