I have a decent amount of knowledge in Liquid and CSS, but struggling to scope styling to a specific blog.
Say there are two blogs: one called “news” and a second called “wallpapers.” There are two different blog post templates, one used for articles posted to News and another used for articles posted to wallpapers.
I want to apply CSS to add a sidebar to the article, but only want it to apply to articles posted under the blog “wallpapers.” How can I accomplish this? Currently, I can code it for .template-article, but of course, that applies to all articles, and I don’t wish it to.
Hello,
To add different layout you should add new template for that.
Go to theme files on live theme > Add new template for blog > Assign it to blogs page
To assign template -
Go to blogs list > Manage Blogs > Select blog type > Assign template
Let me know if any.
Thank you
I understand applying specific article templates to a certain blog. I am asking about applying CSS customizations to a specific template to a certain blog that is not “template wide.” The CSS customizations I add apply to all article templates, whereas I wish for them to apply to articles only under a specific blog. I am asking about which CSS selector I use to scope my CSS rules to a specific blog. Not about applying different article templates to a blog.
For that you may add condition above the css which can make it applied for particular page only.
i.e. -
{% if blog.handle == ‘test’ %}
– CSS –
{% endif %}
Please note - This will not work on “.css” file you have to go with “.css.liquid” extension or add it in some snippet. Hope it’s clear.