This blog post will show you the best practice way to enable Font Awesome icons in Power Pages portals. By default, the portal has icons from Bootstrap called Glyphicons – but you can change to using Font Awesome icons pretty easily.
I know there are a lot of blog posts about this already – and most of them put his code in the header web template or something like that. Not the best practice. So I wanted to show you how to do it properly and introduce you to two new content snippets as well.
Get Font Awesome
We need to let the Power Pages portal know where to get the Font Awesome icon library from. You can get your hands on the link for free, but you will need to sign up – even for the free version.
At this writing moment Font Awesome version 6 is the new kid on the block. Get started by visiting the link below. The Font Awesome website has an intuitive user experience, and I trust that you will figure this step out without my step-by-step instructions.
Get Font Awesome icons here: https://fontawesome.com/
Enable Font Awesome icons in Power Pages portals
To use Font Awesome icons on a website the link be placed in the <head> tag in your HTML, as you can see from the Font Awesome documentation:
Link to this documentation page:
We cannot access and edit the <head> tag directly in Power Pages, but there are content snippets that allow us to add, replace and expand the content of the <head> tag.
Content snippets that apply to <head> tag:
|Head/Bootstrap||Replaces all references to Bootstrap and any other stylesheet. (Not recommended)|
|Head/Fonts||Meant for adding fonts – this is what we’ll use for Font Awesome|
|Head/Bottom||Content will be added to the bottom of the <head> tag|
Note: None of these exists in a portal out-of-the-box, but you can create them yourself.
This content snippet will not exist by default, so we need to create it ourselves. Content snippets are only available through the old Portal Management App at this point in time.
- Open your Power Page portal in the new design studio (edit)
- Click the three dots at the bottom of the left menu
- Click the “Portal Management App” button
A new tab opens with the Portal Management App. It’s a model-driven app that allows you to configure the Power Pages portal in a much more advanced and old-school way than the modern designer.
You can learn more about all the different interfaces for editing Power Apps Portals in my blog post from the link below:
Locate “Content Snippets” in the left menu and click the “+ New” button form the toolbar:
A form will open for you to enter values for the new content snippet.
- Set name to “Head/Fonts”
- Set Website to your Power Page
- Set Type” to HTML
- Select the “HTML” tab in the Value section, and paste the “Kit Code” that you got from the Font Awesome Website.
Save the form, delete your portal cache and reload the portal in the browser. To verify that the reference to Font Awesome en enabled you can open the Developer Tool in the browser, open the <head> tag and search for “fontawesome” to see the results.
Try it out
You can also verify that Font Awesome icons are available by using them on a page. One way to do this is to simply
- Find an icon you like at the Font Awesome Icons library
- Copy the HTML code for that icon
- Open a page in Power Pages Design Studio
- Open the inline editor
- Paste the HTML code in a logical place
Preview the portal to see the changes, and it might look something like this:
You also might want to replace the old-looking Glyphicons with more modern icons. For instance, I replaced the arrow in the breadcrumb with a Font Awesome icon. You can learn how I did that in this blog post:
Make sure that you choose icons that are free and that are on the same version as your kit – unless you pay the full license of course. Whenever an icon isn’t showing correctly that’s usually the reason.
Hope this was helpful! Happy portaling! 😀