Dynamic data sources, also known as dynamic sources, allow merchants to connect input settings to data coming from resources such as products, collections, blogs, and pages as well as metafields and metaobjects. Dynamic sources are connected using section and block settings. Merchants can make these [connections in the theme editor](https://help.shopify.com/manual/metafields/displaying-metafields-on-your-online-store#connecting-metafields-to-your-theme-by-using-the-theme-editor) A dynamic source can be either: - A [resource attribute](#available_shopify_resources_and_attributes) - A [metafield value](#metafield_and_input_setting_compatibility) > Note: > Dynamic sources aren't available for general theme settings. ## Dynamic source type availability Shopify determines the value of each available dynamic source type based on the following: - The resource associated with the template that the section is in - The resource settings in the context of the current setting - Any metaobjects with storefront visibility and compatible fields - [Brand attributes](/docs/api/liquid/objects#brand) - Market-specific metafields and metaobjects <table> <caption>How Shopify determines available values</caption> <thead> <tr> <th scope="col">Conditions</th> <th scope="col">Description</th> </tr> </thead> <tbody> <tr> <td>The section is included as part of the <a href="/docs/storefronts/themes/architecture/templates/product">product template</a></td> <td>Metafields and attributes related to the product will be available for the following: <ul> <li>The section's settings</li> <li>The settings for any block in the section</li> </ul> </td> </tr> <tr> <td>The section includes a <a href="/docs/storefronts/themes/architecture/settings/input-settings#collection">collection type setting</a></td> <td>Metafields and attributes related to the collection will be available for the following: <ul> <li>The section's settings</li> <li>The settings for any block in the section</li> </ul> </td> </tr> <tr> <td><a href="/docs/storefronts/themes/architecture/blocks/theme-blocks/dynamic-sources">Theme Blocks</a> product type setting</td> <td>Theme Blocks access the <a href="https://shopify.dev/docs/storefronts/themes/architecture/blocks/theme-blocks/dynamic-sources#accessing-the-closest-resource">closest resource</a> which matches a resources of specified type. In this case, the nearest product type setting.</td> </tr> <tr> <td>The section's blocks include a <a href="/docs/storefronts/themes/architecture/settings/input-settings#product">product type setting</a></td> <td>Metafields and attributes for that product will be available for the block's settings.</td> </tr> <tr> <td>Globally available metaobjects</td> <td>Metaobjects with storefront visibility will be available as dynamic sources for any theme setting</td> </tr> </tbody> </table> ## Available Shopify resources and attributes The following table lists the available Shopify resources and their associated attributes: <table> <caption>Available resources and their attributes</caption> <thead> <tr> <th scope="col">Resource</th> <th scope="col">Attributes</th> </tr> </thead> <tbody> <tr> <td><a href="/docs/api/liquid/objects/product">product</a></td> <td> <ul> <li> <code>title</code> </li> <li> <code>vendor</code> </li> <li> <code>description</code> </li> <li> <code>url</code> </li> <li> <code>featured_image</code> </li> <li> <code>collections</code> </li> </ul> </td> </tr> <tr> <td><a href="/docs/api/liquid/objects/collection">collection</a></td> <td> <ul> <li> <code>title</code> </li> <li> <code>image</code> </li> <li> <code>description</code> </li> <li> <code>url</code> </li> <li> <code>products</code> </li> </ul> </td> </tr> <tr> <td><a href="/docs/api/liquid/objects#page">page</a></td> <td> <ul> <li> <code>title</code> </li> <li> <code>url</code> </li> <li> <code>content</code> </li> </ul> </td> </tr> <tr> <td><a href="/docs/api/liquid/objects#article">article</a></td> <td> <ul> <li> <code>title</code> </li> <li> <code>url</code> </li> <li> <code>author</code> </li> <li> <code>content</code> </li> <li> <code>excerpt</code> </li> <li> <code>comments_count</code> </li> <li> <code>image</code> </li> </ul> </td> </tr> <tr> <td><a href="/docs/api/liquid/objects#blog">blog</a></td> <td> <ul> <li> <code>title</code> </li> <li> <code>url</code> </li> </ul> </td> </tr> </tbody> </table> > Note: > More resources and resource attributes will become available in the future. ## Metafield and input setting compatibility Metafields allow merchants to define [custom data](https://shopify.dev/docs/apps/build/custom-data). The metafields can be connected to sections and blocks using settings in the theme editor. The following outlines which [setting](/docs/storefronts/themes/architecture/settings/input-settings) and [metafield](/docs/apps/build/custom-data/metafields/list-of-data-types) types are compatible: <table> <thead> <tr> <th>Setting</th> <th>Metafield(s)</th> <th>Metafield validation options</th> </tr> </thead> <tbody> <tr> <td><code>collection</code></td> <td> <ul> <li><code>collection_reference</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>collection_list</code></td> <td> <ul> <li><code>list.collection_reference</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>color</code></td> <td> <ul> <li><code>color</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>image_picker</code></td> <td> <ul> <li><code>file_reference</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>page</code></td> <td> <ul> <li><code>page_reference</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>product</code></td> <td> <ul> <li><code>product_reference</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>product_list</code></td> <td> <ul> <li><code>list.product_reference</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>richtext</code></td> <td> <ul> <li><code>single_line_text_field</code></li> <li><code>list.single_line_text_field</code></li> <li><code>multi_line_text_field</code></li> <li><code>rich_text_field</code></li> <li><code>number_integer</code></li> <li><code>number_decimal</code></li> <li><code>date</code></li> <li><code>date_time</code></li> <li><code>weight</code></li> <li><code>volume</code></li> <li><code>dimension</code></li> <li><code>rating</code></li> <li><code>money</code></li> <li><code>link</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>inline_richtext</code></td> <td> <ul> <li><code>single_line_text_field</code></li> <li><code>list.single_line_text_field</code></li> <li><code>number_integer</code></li> <li><code>number_decimal</code></li> <li><code>date</code></li> <li><code>date_time</code></li> <li><code>weight</code></li> <li><code>volume</code></li> <li><code>dimension</code></li> <li><code>rating</code></li> <li><code>money</code></li> <li><code>link</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>text</code></td> <td> <ul> <li><code>single_line_text_field</code></li> <li><code>list.single_line_text_field</code></li> <li><code>number_integer</code></li> <li><code>number_decimal</code></li> <li><code>date</code></li> <li><code>date_time</code></li> <li><code>weight</code></li> <li><code>volume</code></li> <li><code>dimension</code></li> <li><code>rating</code></li> <li><code>money</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>url</code></td> <td> <ul> <li><code>url</code></li> </ul> </td> <td></td> </tr> <tr> <td><code>video</code></td> <td> <ul> <li><code>file_reference</code></li> </ul> </td> <td> Must accept video file types </td> </tr> <tr> <td><code>metaobject</code></td> <td> <ul> <li><code>metaobject_reference</code></li> </ul> </td> <td> Must be of the same metaobject type as in the setting's schema. </td> </tr> <tr> <td><code>metaobject_list</code></td> <td> <ul> <li><code>list.metaobject_reference</code></li> </ul> </td> <td> Must be of the same metaobject type as in the setting's schema. </td> </tr> </tbody> </table> #### Referencing metaobject fields You can use dynamic sources to connect metaobject fields to settings. Metaobjects can be referenced in two ways: 1. Directly as a dynamic source when the metaobject has storefront visibility and compatible fields (also referred to as globally available metaobjects) 2. Through a `metaobject_reference` metafield When selecting a metaobject as a dynamic source, users can select any field that is compatible with the setting type. For example, if a metaobject has a `text` field and an image field, a `text` setting could use the `text` field as a dynamic source, while an `image_picker` setting could use the image field. In the case of a `list.metaobject_reference`, the metaobject entries attached to the resource are iterated over, and for each metaobject, the selected field's value is displayed in a list. The values are displayed as a list of the selected field's type. For example, if the selected metaobject field is of type `single_line_text_field`, then the values are returned as `list.single_line_text_field`. ##### Example A merchant has a `list.metaobject_reference` metafield that references a **Materials** metaobject. Each metaobject has a field called **Material name**. You can assign the materials by name to the product in the **Metafields** section: ![metafield card with materials](/assets/themes/settings/specialized/metafield-product-example.png) In the online store editor, any setting that supports `list.single_line_text_field`, such as a rich text field, can use dynamic sources to select the **Material name** field as a text source: ![dynamic source popover with metaobject](/assets/themes/settings/specialized/rte-dynamic-sources.png) This outputs a list of the material names associated with the current product: ![list of material names in theme](/assets/themes/settings/specialized/theme-output-rte-list.png) ## Default values You can configure a setting's default value to reference a dynamic source. However, only do this if you're rendering a section or block in a context where the dynamic source value exists. For example, don't use a product-related value in a section that: - Can be rendered in non-product templates - Doesn't explicitly have a `product` type setting to provide the necessary value > Note: > This also applies to setting values in [presets](/docs/storefronts/themes/architecture/sections/section-schema#presets). Additional Liquid is invalid when using this method, so you can only reference the value directly. If you include additional Liquid, then you'll get an error. The following is an example of a `default` setting that references a dynamic source: ```json { "type": "text", "id": "featured_product_title", "label": "Featured product title", "default": "Featuring: {{ product.title }}" } ``` ## Limits Shopify limits the number of dynamic sources that you can use in different areas of your theme. These limits help to keep the theme performant. <table> <caption>Dynamic sources limits</caption> <thead> <tr> <th scope="col">Description</th> <th scope="col">Limit</th> </tr> </thead> <tbody> <tr> <td>Dynamic sources in a <a href="/docs/storefronts/themes/architecture/templates/json-templates">JSON template</a></td> <td>100</td> </tr> <tr> <td>Dynamic sources in <a href="/docs/storefronts/themes/architecture/config/settings-data-json">general theme settings</a></td> <td>100</td> </tr> <tr> <td>Dynamic sources in a <a href="/docs/storefronts/themes/architecture/section-groups">section group</a></td> <td>100</td> </tr> <tr> <td>Dynamic sources in a <a href="/docs/storefronts/themes/architecture/settings/input-settings">single setting</a></td> <td>50</td> </tr> <tr> <td>Dynamic sources in a <a href="/docs/storefronts/themes/architecture/sections#statically-render-a-section">static section</a></td> <td>50</td> </tr> </tbody> </table>