Shopify themes, liquid, logos, and UX
I have followed several tutorials and added the following CSS to test with both base.css and then a custom.css file linked to theme.liquid:
@font-face {
font-family: "smokey";
src: url({{"smokey.woff" | asset_url}}) format("woff"),
url({{"smokey.woff2" | asset_url}}) format("woff2");
}
Both woff & woff2 fonts are uploaded to the assets folder.
I then tried to use font on h2 headers with:
h2 {
font-family: "smokey" !important;
}
The headers change from a sans serif to a serif font (so they are being targeted) but they do not change to the smokey font.
Just wondering if I am doing anything wrong or if this doesn't work with the Dawn 6.0.2 theme.
Cheers!
Solved! Go to the solution
This is an accepted solution.
Hi @chookz,
Try this different approach. You can also try to upload your font this way instead of doing it from the asset folder in your theme.
1. In your Admin store, click Settings on your left hand bottom corner
2. Go to Files, then upload your font.
3. Copy the link when done uploading, and paste it in the font-face. See code below for reference
@font-face {
font-family: 'smokey';
src: url(https://samplelink) format('woff2'),
url(https://samplelink) format('woff');
}
This is an accepted solution.
Hi @chookz,
Try this different approach. You can also try to upload your font this way instead of doing it from the asset folder in your theme.
1. In your Admin store, click Settings on your left hand bottom corner
2. Go to Files, then upload your font.
3. Copy the link when done uploading, and paste it in the font-face. See code below for reference
@font-face {
font-family: 'smokey';
src: url(https://samplelink) format('woff2'),
url(https://samplelink) format('woff');
}
Thank you very much. This worked great. Perhaps just edit your code to put the url sample link in quotation marks for anybody else looking for the same answer. Cheers
Hi,
Your approach is correct.
However you always need to use fallback font.
Please keep your fonts in assets and upload the fonts to your file folder (Admin > Settings > Files )
Please add the code below to Assets/base.css.
@font-face {
font-family:"smokey";
src: url("{{ 'smokey.woff' | asset_url }}") format("woff"),
url("{{ 'smokey.otf' | asset_url }}") format("opentype");
font-display:auto; font-style:normal; font-weight:400; font-stretch:normal;
}
@font-face {
font-family: smokey;
font-weight: 400;
font-style: normal;
font-display: fallback;
src: url("https://cdn.shopify.com/your-font-file-address/") format("woff2"),
url("https://cdn.shopify.com/your-font-file-address/") format("woff");
}
/* Don't remove the header font-familty */
h2 {
font-family: "smokey" !important;
}
Hope it works and helps.
Thanks.
Thank you very much
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024