in my case, I have added this font awesome by declaring it in the header.

is there any way to inject this font awesome by libraries on the resource of my module and not call it externally by link

1 Answer 1

  1. You need to download the fontawesome zip package and add the required css files under your theme. Steps to add the CSS files in your theme:
  • Go to directory app/design/frontend/YourVendor/YourTheme/web/css .
  • Unzip the downloaded fontawesome zip package under fontawesome directory.
  1. To include/call a CSS file, add the <css src="..." /> block in section in a layout file. app/design/frontend/YourVendor/YourTheme/Magento_Theme/layout/default_head_blocks.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <css src="css/all.css" rel="stylesheet" type="text/css" />
        <css src="css/fontawsome.css" rel="stylesheet" type="text/css" />
  1. Deploy your static resources (Theme changes):
  • php bin/magento setup:upgrade
  • php bin/magento setup:static-content:deploy -f
  • php bin/magento cache:flush

Now check your css file will be added on your website.

  • thank you for your reply , i have added a zip folder contains lot of folder , i have on it css/all.css and css/fontawsome.css , i can't find fontawsome-all.css as you said , it didn't work for know
    – magNif
    Nov 3, 2021 at 13:55
  • Yes you have to add your css file path in layout file. Please check my updated answer @magNif. Nov 4, 2021 at 10:34
  • @magNif Please upvote and accept my answer as a solution if it looks helpful to you. Thank you :) Nov 9, 2021 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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