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?

2 Answers 2

  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.


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. Never forget to add the asterisk behind the folders you're deleting since they contain an .htaccess file that might be relevant for your shop to load properly. The asterisk prevents Dot-Files from being deleted.

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.