I created a custom css file in Vendor/theme/web/css and added css/custom.css to my default_head_blocks.xml file. Im in developer mode but I still ran static content deploy -f. I cleaned/flushed cache. My custom css still does not show up in the head.

What else is there to check for?


I Hope this is useful for You,

add your CSS file to





Then add CSS File to Your layout File.


<?xml version="1.0"?>
 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
      <css src="css/mycss.css" />
     <referenceContainer name="content">
          <block class="vendor\Module\Block\class" template="vendor_Module::class.phtml"/>

Remove this folder

 rm -rf var/cache/*
 rm -rf var/page_cache/*

Remove pub/static

rm -rf pub/static 

Next generate Static Content:

php bin/magento setup:static-content:deploy 

Now, try, Its worked for me.

  1. You css file myfile.css should be in : app/design/frontend/{Vendor}/{theme}/web/css/myfile.css

  2. Declared in : app/design/frontend/{Vendor}/{theme}/layout/default_head_blocks.xml

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/framework/Module/etc/module.xsd">
            <css src="css/myfile.css" />
  3. Remove the CONTENT of : pub/static, generated, var/cache, var/page_cache except the .htaccess

  4. launch : php bin/magento setup:static-content:deploy -f

    It should Work.

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.