Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi,
We're moving from Magento to Shopify and I've imported 1000's of pages, many of which have minor CSS tweaks here and there which we'd like to keep.
I've imported most pages weeks ago and they were fine but stating last Friday all CSS rules are getting commented out when you save the page.
Wven weirder, the Shopify editor seems to "apply" the rules even though they were commented but then, obviously, the live page don't.
Before Saving:
After Saving:
After saving (rules commented) showing how the editor still applies the rules:
Live page:
Any idea what's going on?
JFerreira, did you find a solution to this issue? I'm having the same problem.
Dave
Hi @JFerreira and @Bellman61
There is a way to implement custom CSS to individual pages using metafields.
1. Navigate to Settings > Custom Data > Pages
2. Choose "Add definition"
3. Create your metafield
4. Navigate to the editor for the Page you'd like to apply the custom CSS code to. Under the Page description, you should now see a section for your Metafield. Choose "Show all"
5. Click into your Custom CSS metafield, and simply add your custom CSS to this field. Save when you're finished.
6. Navigate to your Online Store Sales Channel. Click the 3 dots on your current theme next to the "Customize" button. Choose, "Edit code"
7. On the lefthand side, select your "theme.liquid" file
8. READ NOTE BELOW BEFORE CONTINUING: Within your theme code, scroll down and find the closing </head> tag. Just above this, insert the following code using the Namespace and key that you created. You'll need to include the opening and closing <style> tags. Within the <style> tag, it should read {{ page.metafields.namespace.key }}, which in our example is {{ page.metafields.custom_store_code.css }}.
NOTE: Editing your theme.liquid file will affect your entire site. Be very cautious within this file, however after you have saved any changes, you can restore previous versions of your theme.liquid file by clicking the "Current" selector underneath "Recent changes" if you need to revert back. It is also a good idea to copy and paste this entire file to a notepad before you start making any changes, just to have a hardcoded backup.
9. Save your theme.liquid file, and you should now see the custom code applied to the individual page you edited.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024