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

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

1 Answer 1

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!!!

5
  • ok . could you please suggest the good path & method to put new style sheet in my website .
    – John
    Commented Sep 2, 2019 at 8:06
  • I've updated my answer, please have a review.
    – Sumit
    Commented Sep 2, 2019 at 8:49
  • 1
    very useful information . thank you very much
    – John
    Commented Sep 2, 2019 at 8:57
  • You're welcome, John. Happy coding!!!
    – Sumit
    Commented Sep 2, 2019 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
    Commented Sep 2, 2019 at 9:01

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.