Skip to main content

Optimizely

How to Use Fonts in Optimizely CMS Spire

Getting Down To Work

Unlock Your Website’s Potential with Custom Fonts

In this blog, we’ll explore the importance of typography in enhancing your site’s visual appeal and user experience. You’ll discover step-by-step instructions for integrating custom fonts into your Optimizely CMS Spire. Whether you’re a beginner or an experienced developer, this guide will provide valuable insights to elevate your web design.

So, let’s see below how we can integrate fonts using a third-party URL or by using font files. 

URL Font Help 

If you need to use third-party font URLs, such as Google Fonts or Adobe Fonts, then this option is preferable. 

By default, Optimizely uses this one option to load font.  

Suppose we have already created blueprint (or We can say theme in general) i.e. CustomBlueprint under frontend/modules/blueprints directory. 

We must create the Start.tsx file if it is not already in the CustomBlueprint/src directory. 

There is variable called fontFamilyImportUrl present under typography section of file modules\mobius\src\globals\baseTheme.ts. Use the variable that was copied from the previously specified file location in Start.tsx.

Inside that variable we must update whatever third-party URL we have (Google Font, Adobe Font, etc).

 

Fonts import with URL option

 

Once you’ve updated the URL as mentioned above, you can start using the font as outlined below. 

 

Fonts use in Start.tsx file with url option

Custom Fonts

If you want to load font files from codebase instead of using third-party font URLs. Then this option is preferable.  

Let’s see how we can integrate fonts using custom font files like (woff, woff2, eot, ttf).  

Here also we need CustomBlueprint blueprint and Start.tsx file.  

First, we will see where we must add a custom font file and then how to access and load in our site those files.  

 

Fonts files in static content

 

Under CustomBlueprint create the wwwroot/staticContent directory, and inside that directory, add your font files. 

Also, create one CSS file stylesheet.css under wwwroot/staticContent directory. Inside that file we are calling the fonts file using @font-face.

 

Fonts import using stylesheet file

 

Once font added under directory wwwroot/ staticContent and called in wwwroot/ staticContent/stylesheet.css CSS file, then we have to assign path of CSS file to “fontFamilyImportUrl” variable present in Start.tsx file. 

Fonts import using files in Start.tsx file

 

By using this path /staticContent/stylesheet.css, you can access CSS file.

Once above process done then you can start using font as per below.

 Fonts use in Start.tsx file with code option

 

 

By using the above two ways, you can easily integrate fonts in your Optimizely CMS spire site. 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Purushottam Rathi

As a Senior Technical Consultant at Perficient, Purushottam brings over four years of experience in front-end development, specializing in Magento and Optimizely within the E-commerce domain. He is deeply passionate about technology, consistently shares knowledge with his team, and continuously pursues learning opportunities in emerging technologies.

More from this Author

Categories
Follow Us