I'm new to Magento 2.

I would like to know how to use font awesome icons in my magento 2 project particularly in linking the cdn url to my project where about would I add this link?



To add external static resources like CSS, JavaScript, Web fonts (Fontawesome in this case), Please follow the steps below.

  1. Go to this link and copy the CDN URL of Fontawesome.

  2. Find the file app/design/frontend/{Themevendor}/{Themename}/Magento_Theme/layout/default_head_blocks.xml and paste the line below. (The line should be placed in the head tag and the value of src_type should be url.)

<css src="https://use.fontawesome.com/releases/v5.2.0/css/all.css" src_type="url"/>

For details please visit this Magento 2 devdocs link

| improve this answer | |

You have to use absolute url instead of relative url to import font in css file like :

../font/fontfilename => http://www.yourdomain/skin/frontend/namespace/theme/font/fontfilename
| improve this answer | |
  • Hi Where Do i place this line of code? – Jiyaad.D Aug 19 '16 at 6:46
  • Folder path :: /app/design/frontend/your themes package structure/web/css/fontawesome/font-awesome.css – Ashish Jagnani Aug 19 '16 at 6:55
  • According to Magento 2 and your folder structure you have to change the font url. – Ashish Jagnani Aug 19 '16 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.