Coders Create

Coders Create
Coders Create
Coders Create

How to Add Custom Sections to Your Shopify Store

In this post, we’ll break down what reverse dropshipping is, why it’s beneficial, and highlight some top product categories to consider if you’re thinking about exploring this business model.

 

As a Shopify store owner, having the flexibility to customize your store layout and content is crucial for building a unique brand identity. Thankfully, Shopify’s dynamic sections make it easier than ever to create custom layouts without having to dive deep into code. In this tutorial, we’ll walk you through how to add custom sections to your Shopify store, whether you’re using a pre-built theme or creating something entirely from scratch.

What Are Shopify Sections?

Before we dive into the process, let’s break down what sections are. Shopify sections are customizable, modular blocks that allow you to control the layout and content of your store pages. Shopify introduced sections to give merchants more flexibility in designing their pages without requiring advanced coding knowledge. You can think of sections as “building blocks” that can be rearranged or customized to display different content on your homepage, product pages, collection pages, and more.

There are two types of sections in Shopify:

  1. Static Sections: These are sections that appear on every page, like the header, footer, or navigation.
  2. Dynamic Sections: These are sections you can drag and drop into specific templates, such as on the homepage, allowing for greater flexibility.

Why Add Custom Sections?

Adding custom sections can help you:

  • Showcase unique content, such as a promotional banner, testimonials, or a featured collection.
  • Increase engagement by adding dynamic elements like videos, sliders, or product carousels.
  • Personalize your store’s design to match your brand identity.

Step-by-Step Guide: How to Add a Custom Section to Your Shopify Store

Step 1: Access Your Shopify Admin

Start by logging into your Shopify admin. Navigate to Online Store > Themes and then click on Actions > Edit Code for the theme you want to customize.

Step 2: Create a New Section

Next, you’ll need to create a new section file. In the left sidebar, scroll down to the Sections folder and click Add a new section. Give your section a descriptive name like custom-banner or featured-products.

This will generate a blank Liquid file for your section.

Step 3: Add HTML, Liquid, and CSS

In this step, you’ll add the structure and styling for your custom section. For example, if you’re creating a banner section, your code might look like this:

<!-- custom-banner.liquid -->
<section class="custom-banner">
  <div class="banner-content">
    <h2>{{ section.settings.banner_heading }}</h2>
    <p>{{ section.settings.banner_text }}</p>
    <a href="{{ section.settings.banner_link }}" class="banner-button">{{ section.settings.banner_button_text }}</a>
  </div>
</section>

Here’s a breakdown of what’s happening:

  • We’ve created a custom-banner section with HTML.
  • The content, like the banner heading and text, is being pulled from the section’s settings using Liquid.
  • The button links to a customizable URL, also defined in the settings.

Step 4: Add Schema for Section Settings

To allow the store owner (or you) to customize the section without editing code every time, we need to define some settings using Shopify’s schema. Here’s how you can define settings for the heading, text, link, and button text:

{% schema %}
{
  "name": "Custom Banner",
  "settings": [
    {
      "type": "text",
      "id": "banner_heading",
      "label": "Banner Heading",
      "default": "Welcome to Our Store"
    },
    {
      "type": "textarea",
      "id": "banner_text",
      "label": "Banner Text",
      "default": "We offer the best products."
    },
    {
      "type": "url",
      "id": "banner_link",
      "label": "Banner Link",
      "default": "/collections/all"
    },
    {
      "type": "text",
      "id": "banner_button_text",
      "label": "Button Text",
      "default": "Shop Now"
    }
  ],
  "presets": [
    {
      "name": "Custom Banner",
      "category": "Banner"
    }
  ]
}
{% endschema %}

In this schema block:

  • We’ve created editable fields for the heading, text, link, and button text.
  • The presets section defines the default values for the section when it’s first added to the theme.

Step 5: Add Your Section to a Page Template

Now that the section is created, you need to add it to a page, such as your homepage. Open the Templates > index.liquid file (or another template, depending on where you want the section to appear) and add the following code where you want the section to be displayed:

{% section 'custom-banner' %}

This will render the custom section you just created on the homepage.

Step 6: Customize the Section in Theme Editor

Go back to your Shopify admin and navigate to Online Store > Themes. Click Customize on the theme you are editing. You’ll now see your new custom section available under the “Sections” tab. You can customize the heading, text, link, and button directly through the Shopify theme editor without touching any code.

Simply drag and drop the section into place and update its content as needed.

Tips for Creating Custom Sections

  • Use Tailwind CSS: If you’re comfortable with Tailwind, you can use its utility classes to style your section for a modern and responsive design.
  • Preview Changes: Always preview your changes in the theme editor to ensure your section looks good on both desktop and mobile views.
  • Add More Settings: You can get creative with additional settings like color pickers, image uploads, or video embeds to make your custom section even more dynamic.

Conclusion

Custom sections are a powerful way to make your Shopify store more engaging and tailored to your brand. Whether you’re adding promotional banners, product showcases, or customer testimonials, following these steps will help you easily create and customize sections to fit your needs.

With Shopify’s drag-and-drop capabilities, combined with a little bit of Liquid and CSS, you’ll have full control over how your store looks and functions.

Need Help with Shopify Customization? If you’re looking for assistance with adding custom sections or any other Shopify development needs, feel free to contact me for a consultation!