Hi! I would like to add at rules (css) to my website and for what I’ve been reading the only way to do it is to add the code to the theme.css file. I wonder if altering the theme’s code would be a problem in case a new update comes out.
In that case, could I update the theme without problem? And if I do, would the code I’ve added be lost?
Thank you!
If you edit the theme.css file directly, any changes you make will be overwritten when you update the theme. However, you can avoid this problem by creating a new CSS file with your custom rules and linking to it in your theme’s code instead of editing the theme.css file directly.
To do this, you can create a new file in your Shopify theme’s assets directory, such as “custom.css”. Then, add your custom CSS rules to that file. Finally, in your theme’s code, add a link to your new CSS file by adding the following code to your theme.liquid or theme.scss.liquid file:
<link rel="stylesheet" type="text/css" href="{{ 'custom.css' | asset_url }}" />
Wonderful!! thank you so much! One last question: if I ever update the theme I would need to add once again the following code to the theme.liquid or theme.scss.liquid file:
<link rel="stylesheet" type="text/css" href="{{ 'custom.css' | asset_url }}" />
right?
I just tried and it’s not working 