skip to Main Content

I am new to creating sections in Shopify and I am getting an invalid JSON in tag ‘schema’ error. I am trying to create a static section in my footer with a heading and image that links with a URL. Any help will be much appreciated.

{% schema %}
  {
    "name": "Footer Image",
    "class": "image",
    "settings":     [
                {
            "id":"footer-image-heading",
            "type":"text",
            "label":"footer-image-heading",
            "default": "Enter heading text here",
        },

                {
            id":"footer-image",
            "type":"image_picker",
            "label":footer-image",
            
        },

                {
            id":"footer-image-url",
            "type":"url",
            "label":"footer-image-url",
            "default": "Enter url here",
            
        },
    ]
}
{% endschema %}

2

Answers


  1. You are missing some double quotes and also you shouldn’t have any commas on the last element.

    On a side note, elements with type: url do not accept "default" parameter. Here’s the fixed code which should work for you.

    {% schema %}
        {
            "name": "Footer Image",
            "class": "image",
            "settings":     [
                {
                    "id": "footer-image-heading",
                    "type": "text",
                    "label": "footer-image-heading",
                    "default": "Enter heading text here"
                },
                {
                    "id": "footer-image",
                    "type": "image_picker",
                    "label": "footer-image"
    
                },
                {
                    "id": "footer-image-url",
                    "type": "url",
                    "label": "Enter url here"
                }
            ]
        }
    {% endschema %}
    
    Login or Signup to reply.
  2. There are too many issues with your JSON before we begin with the section issue first.

    Validate your JSON here: https://jsonformatter.curiousconcept.com/

    Here are some of the issues:

    • there are trailing , that shouldn’t be there, example "default": "Enter heading text here", / "default": "Enter url here",
    • you have missing quotes – example id" / footer-image"

    As for the Shopify section issue, URL fields, doesn’t have a default field, so this is wrong "default": "Enter url here",.

    Your section JSON should look like this:

    {% schema %}
      {
        "name": "Footer Image",
        "class": "image",
        "settings":     [
            {
                "id":"footer-image-heading",
                "type":"text",
                "label":"footer-image-heading",
                "default": "Enter heading text here"
            },
    
            {
                "id":"footer-image",
                "type":"image_picker",
                "label":"footer-image"
            },
    
            {
                "id":"footer-image-url",
                "type":"url",
                "label":"footer-image-url"
            }
        ]
    }
    {% endschema %}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search