0

I have added css on custom phtml file using:

<link rel="stylesheet" type="text/css" href="<?php echo $block->getViewFileUrl('css/banner.css')?>">

and placed the CSS file in folder: Magento_Theme/web/css When I load page and view the page content source it shows the CSS path as:

<link rel="stylesheet" type="text/css" href="http://xyz/magento-2/pub/static/version1530249778/frontend/Magento/mytheme/en_US/css/banner.css">

But not created any file on pub/static folder. I have cleared the cache and run the upgrade command.

Thanks

asked Jun 29, 2018 at 5:42

1 Answer 1

0

If your css file in Magento_Theme folder then you should follow this code:

<link rel="stylesheet" type="text/css" href="<?php echo $block->getViewFileUrl('Magento_Theme::css/banner.css')?>">

I hope it will works.

answered Jun 29, 2018 at 5:49
6
  • <?php echo $block->getViewFileUrl('css/banner.css')?> why it not created on path mytheme/en_US/css/ ? Commented Jun 29, 2018 at 6:13
  • I want to create the css on path mytheme/en_US/css/ Commented Jun 29, 2018 at 6:14
  • Then you should write like this: <link rel="stylesheet" type="text/css" href="<?php echo $block->getViewFileUrl('css/banner.css')?>"> & your css file in app/design/frontend/Vendor_Name/Theme_Name/web/css/file_name.css. folder. Commented Jun 29, 2018 at 6:19
  • After that you need to setup upgrade & deploy static content data. Commented Jun 29, 2018 at 6:21
  • M2 very complex as compare to old magento, anyway thanks Commented Jun 29, 2018 at 6:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.