1

I am very new to Magento. Recently I have to add extra styles to my magento website. So I go to adminpanel -> content-> design->configuration->my theme ->HTML Head

I add the following line

<link rel="stylesheet" type="text/css" media="all" href="https://example.com/my-style/style.css" />

Then I save that one. Now new styles are working on my website. But I edited some of the styles through opening the file through Filezilla and edit. After that, I uploaded. Then I noticed that new changes are not coming. So I open https://example.com/my-style/style.css in a browser so I can see that it is not updated the copy. I refresh the page and I open in incognito window. Still the same. But when I open in the same file through editor using FileZilla I can see that it is updated copy.

Then I try to refresh page cache, layout cache but the result is the same.

i am using FileZilla for accessing the file . i don't have the terminal . Please help

  • try sudo rm -rf var/cache/* generated/* pub/static/* php bin/magento setup:di:compile php bin/magento setup:upgrade – Shafeel Sha Jul 30 at 8:51
  • i dont understand. this is any command line ? whee i have to execute ? – John Jul 30 at 9:57
  • did you try after clear cache/ generated and static folders ? – Shafeel Sha Jul 30 at 10:03
  • no . Because i dont know how to do that . I try to refresh page cache, layout cache . – John Jul 30 at 12:34
  • please check answer – Shafeel Sha Jul 30 at 13:20
1

As you've said that, you've inserted the CSS file directly on in the header which is placed under /var/www/html/my-style/style.css.

You need to flush the CDN and Server caches as well if they are enabled on the website.

As you've shared, your site has enabled the Cloudfare, then you need to flush the cache for the below path from Cloudfare

/var/www/html/my-style/style.css

Also, you can add a custom CSS file in your theme by adding a CSS file to the below path:

/app/design/frontend/[vendor]/[your_theme]/web/css/your_css_file

Include the created file by adding it to /app/design/frontend/[vendor]/[your_theme]/Magento_Theme/layout/default_head_blocks.xml with below content.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="css/your_css_file.css" />
    </head>
</page>

Below is the official guide to include custom CSS files in your theme.

https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/css-topics/css-themes.html

Hope it helps!!!

  • ok . could you please suggest the good path & method to put new style sheet in my website . – John Sep 2 at 8:06
  • I've updated my answer, please have a review. – Sumit Sep 2 at 8:49
  • 1
    very useful information . thank you very much – John Sep 2 at 8:57
  • You're welcome, John. Happy coding!!! – Sumit Sep 2 at 8:58
  • 1
    before i am searching for official magento documentation , that time i didn't find out . But now you helped me to get the documentation . Really thank you . – John Sep 2 at 9:01
0

Open Terminal by pressing alt + ctrl + t and find your magento2 project root folder [example : /var/www/html/magentoProjectFolder/ ] then Follow below commands.

 php bin/magento cache:flush
 php bin/magento cache:clean
 sudo chmod -R 777 pub/* var/* generated/*
  • but where i will write this commands ? in cmd ? which path ? I have aws server – John Aug 1 at 6:29
  • please check updated answer !! – Shafeel Sha Aug 1 at 6:42
  • hi , i am using filezila for editing the file . i don't have the terminal . Please help – John Sep 2 at 7:26

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.