How to Use Body Classes in BigCommerce

· Kal Wiggins
Share
How to Use Body Classes in BigCommerce

If you’re managing a BigCommerce store and want to level up your CSS and JavaScript targeting, this video is exactly what you need. In this guide, I walk you through how to use body classes to target specific pages, categories, and products on your store. These body classes will give you finer control over your styling and functionality, helping you create more tailored user experiences.

Before diving into the details, make sure to watch the full video below. I cover everything step-by-step, including tips and tricks that have helped me after years of BigCommerce development.

Key Takeaways from the Video:

  1. What Are Body Classes in BigCommerce?
    Learn how body classes help you target specific pages and elements using CSS and JavaScript, giving you more precision in your customizations (00:02).
  2. Why Prepending Body Classes Matters
    Avoid conflicts by prepending your body classes to prevent them from clashing with existing classes in your theme (01:47).
  3. Using Conditional Logic for Cleaner Code
    Implement if statements to ensure body classes only appear when needed, such as when a user belongs to a specific customer group (03:24).
  4. Leverage Dash Case Formatting
    Clean up your body class names by converting spaces to dashes and making everything lowercase. This helps you avoid any unwanted conflicts with other page elements (05:10).
  5. How to Implement Body Classes in Your Theme
    See a practical demonstration of adding body classes to your BigCommerce theme’s base HTML file. Learn how to target specific pages, categories, and products for customization (09:10).

By the way, here’s the exact body classes I use currently:

store-{{ settings.store_hash }} pagetype-{{page_type}} {{#if customer.customer_group_name }} customergroup-{{dashcase customer.customer_group_name}}{{/if}}{{#if product.id }} productid-{{product.id}}{{/if}}{{#if page.title}} pagetitle-{{dashcase page.title}}{{/if}}{{#if category.name}} category-{{dashcase category.name}}{{/if}}{{#if category.id}} category-{{category.id}}{{/if}}{{#if brand.name}} brand-{{dashcase brand.name}}{{/if}}

By the end of this video, you’ll have a solid understanding of how to use body classes to create more powerful and dynamic pages on your BigCommerce store.

👉 Watch the full video now and start implementing these tactics in your store today!

About The Author

Kal Wiggins

Kal Wiggins

Kal Wiggins is the CEO of Epic Design Labs, specializing in ecommerce design and development. As an ecommerce store owner and seasoned developer, Kal shares practical tips and strategies to help fellow store owners grow their businesses.

Related Resources

View All →
Where is the Sitemap on BigCommerce?

Where is the Sitemap on BigCommerce?

Are you trying to find your sitemap on BigCommerce but aren’t sure where to look? Whether you’re submitting your sitemap \[…\]

What size should your hero image be

What size should your hero image be

In the vast realm of e-commerce, mobile images and web desChoosing the right size for your hero image is crucial \[…\]

What is the BigCommerce API

What is the BigCommerce API

If you’ve been working in ecommerce, especially with BigCommerce, you’ve probably heard the term “API” thrown around. But what exactly \[…\]

What is BigCommerce Stencil?

What is BigCommerce Stencil?

If you are still using the BigCommerce Blueprint theme framework, it’s high time that you switched over to their new \[…\]

Welcome to Epic Page Builder Widgets

Welcome to Epic Page Builder Widgets

If you’re running an ecommerce store on BigCommerce, streamlining your page design without the constant need for developers is crucial. \[…\]

Stencil Local Development – Walkthrough

Stencil Local Development – Walkthrough

If you’re looking to develop on BigCommerce, using Stencil Local Development is a game-changer. In this video, I walk you \[…\]

Remove Powered by BigCommerce Link

Remove Powered by BigCommerce Link

If you’re running a BigCommerce store and want to remove the Powered by BigCommerce link at the bottom of your \[…\]

Page Builder Fields In Raw HTML BigCommerce Page Template

Page Builder Fields In Raw HTML BigCommerce Page Template

Are you trying to create custom landing pages on BigCommerce but struggling with how to use Page Builder fields in \[…\]

Most Popular Products on BigCommerce

Most Popular Products on BigCommerce

Understanding Top Sellers and Customizing Your Store If you’re wondering how to display BigCommerce’s most popular products feed on your \[…\]

Want to Grow YOUR Ecom Brand?

We're passionate about our work and inspired to help fervent ecommerce store owners like yourself. Share your vision with us, and we'll help it come to fruition.

Discover how a quick conversation could change your business for the better

Start the Convo