1

Having trouble getting past 404 errors with css and js.

/Vendor/Module/view/frontend/layout/routeid_index_index.xml


<?xml version="1.0" ?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Vendor_Module::css/custom.css" />
        <script src="Vendor_Module::js/custom.js"/>
    </head>
    <body>
        <referenceContainer name="content">
            <block class="Vendor\Module\Block\Display" name="Display" template="Vendor_Module::index.phtml" />
        </referenceContainer>
    </body>
</page>

Files are located here

/Vendor/Module/etc/frontend/web/css/custom.css
/Vendor/Module/etc/frontend/web/js/custom.js

static deploy doesn't seem to do the trick nor does manually clearing the cache

  • /Vendor/Module/etc is always for configuration and di files. – Vivek Kumar Oct 2 '17 at 5:27
2

You have to keep file inside view folder instead of etc folder. New path will be,

/Vendor/Module/view/frontend/web/css/custom.css
/Vendor/Module/view/frontend/web/js/custom.js

Run upgrade and deploy command.

php bin/magento setup:upgrade
rm -rf pub/static/frontend/* pub/static/adminhtml/* var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ var/composer_home
php -dmemory_limit=6G bin/magento setup:static-content:deploy
chmod -Rf 777 pub/ var/

Thank you.

  • Thanks, I was coding in the middle of the night and just couldn't see it – ert3 Oct 2 '17 at 14:34

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.