How to Add Custom Liquid Blocks to Your Shopify Footer

Published on Aug 11, 2024

By Liam Gallagher

#Shopify#Web Development#E-commerce
Woman in White Dress Standing in Front of White Wooden Desk

Are you looking to enhance your Shopify store’s footer with custom content? Adding a custom liquid block to your footer can provide a powerful way to display dynamic information, improve user experience, and boost your site’s functionality. In this comprehensive guide, we’ll walk you through the process of adding a custom liquid block to your Shopify footer, with a focus on the popular Dawn theme.

Understanding Custom Liquid Blocks in Shopify

Before we dive into the implementation, let’s briefly explore what custom liquid blocks are and why they’re valuable for your Shopify store.

What Are Custom Liquid Blocks?

Custom liquid blocks are snippets of code that allow you to insert dynamic content into your Shopify theme. They use Liquid, Shopify’s templating language, to render content that can change based on various conditions or data from your store.

Benefits of Using Custom Liquid Blocks

  1. Flexibility: Custom blocks allow you to add unique features to your store without extensive theme modifications.
  2. Dynamic Content: Display content that updates automatically based on your store’s data.
  3. Improved User Experience: Provide additional information or functionality to your customers right in the footer.

Adding a Custom Liquid Block to Your Footer

Now, let’s get into the step-by-step process of adding a custom liquid block to your Shopify footer. We’ll focus on the Dawn theme, but these steps can be adapted for other themes as well.

Step 1: Accessing Your Theme Files

  1. Log in to your Shopify admin panel.
  2. Navigate to “Online Store” > “Themes”.
  3. Find your active theme (in this case, Dawn) and click “Actions” > “Edit code”.

Step 2: Modifying the Footer Liquid File

  1. In the theme editor, locate and open the footer.liquid file.
  2. Scroll down to find the {% schema %} section.

Step 3: Adding the Custom Liquid Block Schema

Add the following code immediately after the opening {% schema %} tag:

{
  "name": "t:sections.footer.name",
  "blocks": [
    {
      "name": "custom liquid",
      "type": "custom_liquid",
      "settings": [
        {
          "type": "text",
          "id": "heading",
          "default": "Custom Liquid",
          "label": "t:sections.footer.blocks.text.settings.heading.label"
        },
        {
          "type": "liquid",
          "id": "custom_liquid",
          "label": "t:sections.custom-liquid.settings.custom_liquid.label",
          "info": "t:sections.custom-liquid.settings.custom_liquid.info"
        }
      ]
    },
    // ... (existing blocks)
  ],
  // ... (existing settings)
}

This code defines a new block type called “custom liquid” with settings for a heading and custom liquid content.

Step 4: Rendering the Custom Liquid Block

To render the custom liquid block, add the following code after the {% case block.type %} statement in your footer.liquid file:

{% when 'custom_liquid' %}
  {% if block.settings.heading != blank %}
    <h2 class="footer-block__heading">{{ block.settings.heading | escape }}</h2>
  {% endif %}
  {{ block.settings.custom_liquid }}

This code checks for the custom liquid block type and renders the heading (if provided) and the custom liquid content.

Step 5: Save and Test

  1. Save your changes to the footer.liquid file.
  2. Preview your theme to ensure the changes are working correctly.

Customizing Your Footer with Liquid Content

Now that you’ve added the ability to use custom liquid blocks in your footer, let’s explore some practical examples of what you can do with this new feature.

Example 1: Displaying Dynamic Store Information

You can use custom liquid to display dynamic information about your store, such as operating hours or contact details:

{% if shop.address %}
  <p>Visit us at: {{ shop.address }}</p>
{% endif %}

{% if shop.phone %}
  <p>Call us: {{ shop.phone }}</p>
{% endif %}

Example 2: Adding Social Media Links

Create a dynamic list of social media links based on your store’s settings:

<ul class="social-links">
  {% if settings.social_twitter_link != blank %}
    <li><a href="{{ settings.social_twitter_link }}">Twitter</a></li>
  {% endif %}
  {% if settings.social_facebook_link != blank %}
    <li><a href="{{ settings.social_facebook_link }}">Facebook</a></li>
  {% endif %}
  {% if settings.social_instagram_link != blank %}
    <li><a href="{{ settings.social_instagram_link }}">Instagram</a></li>
  {% endif %}
</ul>

Example 3: Showcasing Featured Products

Display a selection of featured products in your footer:

<div class="footer-featured-products">
  <h3>Featured Products</h3>
  {% for product in collections.featured.products limit: 3 %}
    <div class="footer-product">
      <a href="{{ product.url }}">
        <img src="{{ product.featured_image | img_url: '100x100' }}" alt="{{ product.title }}">
        <p>{{ product.title }}</p>
      </a>
    </div>
  {% endfor %}
</div>

Troubleshooting Common Issues

When working with custom liquid blocks in your footer, you might encounter some challenges. Here are some common issues and their solutions:

Issue: Custom Liquid Not Rendering

If your custom liquid content isn’t appearing in the footer, double-check that you’ve correctly added the block type to the schema and included the rendering code in the appropriate place within the footer.liquid file.

Issue: Styling Conflicts

Custom content may not always align with your theme’s existing styles. You may need to add custom CSS to ensure your new footer content looks consistent with the rest of your theme.

Issue: Performance Concerns

Be mindful of the complexity of your custom liquid code. Overly complex operations can slow down your page load times. If you’re experiencing performance issues, consider optimizing your liquid code or moving complex operations to a separate app or backend process.

Best Practices for Footer Customization

To make the most of your custom footer content, keep these best practices in mind:

  1. Keep It Relevant: Only add information to your footer that provides value to your customers.
  2. Maintain Consistency: Ensure that your custom content matches the style and tone of the rest of your site.
  3. Test Thoroughly: Always test your changes across different devices and browsers to ensure compatibility.
  4. Update Regularly: Keep your custom content up-to-date, especially if it includes time-sensitive information.

By following this guide, you should now be able to add custom liquid blocks to your Shopify footer, enhancing your store’s functionality and providing a better experience for your customers. Remember to experiment with different types of content to find what works best for your unique store and audience.

Take Our Quick Quiz:

Which primary product image do you think has the highest conversion rate?