Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Liquid code is not working in css file

Liquid code is not working in css file

ertanb
Shopify Partner
13 0 3

Hi, i am trying to add some liquid code in a css file, but it seems to always be empty when its rendered. 

 

I have a section with the following schema:

 

 

{% schema %}
{
  "settings": [
    {
      "type": "number",
      "id": "margin_top",
    },
    {
      "type": "number",
      "id": "margin_bottom",
    }
  ],
  "presets": [
    {
      "category": "Custom",
      "settings": {
        "margin_top": 30,
        "margin_bottom": 30
      }
    }
  ]
}
{% endschema %}

 

 

 

Then i have created a file under `Assets/my-style.css.liquid`:

 

 

.my-wrapper {
  position: relative;
  margin-top: {{ settings.margin_top }} px;
  margin-bottom: {{ settings.margin_bottom }} px;
}

 

 

 

And i am importing the css in liquid file:

{{ 'my-style.css' | asset_url | stylesheet_tag }}

 

 

 

But when its being rendered its always as :

 

 

.my-wrapper {
  position: relative;
  margin-top: px;
  margin-bottom: px;
}

 

 

 

So, it cant find the settings from the liquid file. Is it any way to solve it?

Replies 2 (2)

Dan-From-Ryviu
Shopify Partner
11522 2254 2435

You must add code to a liquid file, for example like the image below

Screenshot_1.jpg

- Helpful? Like & Accept solution! - Support me? Buy me a coffee
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...
Sign up now.

ertanb
Shopify Partner
13 0 3

Yeah, i understand that. I was looking on whether its possible to have liquid code in a `.css` file.