Resource

Shopify Liquid code examples

Build and customize themes faster with component-based Liquid examples

Featured text

Last updated: Feb 21, 2019

Sections

This dynamic section will create an option for featured text on a store's homepage. This allows merchants to add their own custom content or messaging in any position on the page.

  1. Create a new file within the sections folder of your theme, and paste the code below into this file. Name file featured-text.liquid.
  2. Navigate to the theme editor and select "Add section". Within the Text category, there will be an option for "Rich Text". Custom content can be added here.
<h2>{{ section.settings.section_title | escape }}</h2>
{{ section.settings.text }}

{% schema %}
{
  "name": "Rich text",
  "settings": [
    {
      "type": "text",
      "id": "section_title",
      "label": "Title",
      "default": "Talk about your brand"
    },
    {
      "type": "richtext",
      "id": "text",
      "label": "Text",
      "default": "<p>Use this text to share information about your brand with your customers. Describe a product, share announcements, or welcome customers to your store.</p>"
    }
  ],
  "presets": [
    {
      "name": "Rich Text",
      "category": "Text"
    }
  ]
}
{% endschema %}

Please note: We have intentionally limited CSS and JavaScript, and removed translation strings in order to keep these examples compatible with any theme. Any CSS we have included is for accessibility or rendering purposes.