Skip to main content

Dynamic data sources

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

A dynamic source can be either:

Note

Dynamic sources aren't available for general theme settings.


Anchor to Dynamic source type availabilityDynamic 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
  • Market-specific metafields and metaobjects
How Shopify determines available values
ConditionsDescription
The section is included as part of the product templateMetafields and attributes related to the product will be available for the following:
  • The section's settings
  • The settings for any block in the section
The section includes a collection type settingMetafields and attributes related to the collection will be available for the following:
  • The section's settings
  • The settings for any block in the section
Theme Blocks product type settingTheme Blocks access the closest resource which matches a resources of specified type. In this case, the nearest product type setting.
The section's blocks include a product type settingMetafields and attributes for that product will be available for the block's settings.
Globally available metaobjectsMetaobjects with storefront visibility will be available as dynamic sources for any theme setting

Anchor to Available Shopify resources and attributesAvailable Shopify resources and attributes

The following table lists the available Shopify resources and their associated attributes:

Available resources and their attributes
ResourceAttributes
product
  • title
  • vendor
  • description
  • url
  • featured_image
  • collections
collection
  • title
  • image
  • description
  • url
  • products
page
  • title
  • url
  • content
article
  • title
  • url
  • author
  • content
  • excerpt
  • comments_count
  • image
blog
  • title
  • url
Note

More resources and resource attributes will become available in the future.


Anchor to Metafield and input setting compatibilityMetafield and input setting compatibility

Metafields allow merchants to define custom data. The metafields can be connected to sections and blocks using settings in the theme editor.

The following outlines which setting and metafield types are compatible:

SettingMetafield(s)Metafield validation options
collection
  • collection_reference
collection_list
  • list.collection_reference
color
  • color
image_picker
  • file_reference
page
  • page_reference
product
  • product_reference
product_list
  • list.product_reference
richtext
  • single_line_text_field
  • list.single_line_text_field
  • multi_line_text_field
  • rich_text_field
  • number_integer
  • number_decimal
  • date
  • date_time
  • weight
  • volume
  • dimension
  • rating
  • money
  • link
inline_richtext
  • single_line_text_field
  • list.single_line_text_field
  • number_integer
  • number_decimal
  • date
  • date_time
  • weight
  • volume
  • dimension
  • rating
  • money
  • link
text
  • single_line_text_field
  • list.single_line_text_field
  • number_integer
  • number_decimal
  • date
  • date_time
  • weight
  • volume
  • dimension
  • rating
  • money
url
  • url
video
  • file_reference
Must accept video file types
metaobject
  • metaobject_reference
Must be of the same metaobject type as in the setting's schema.
metaobject_list
  • list.metaobject_reference
Must be of the same metaobject type as in the setting's schema.

Anchor to Referencing metaobject fieldsReferencing 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.

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

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

This outputs a list of the material names associated with the current product:

list of material names in theme

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.

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:

{
"type": "text",
"id": "featured_product_title",
"label": "Featured product title",
"default": "Featuring: {{ product.title }}"
}

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.

Dynamic sources limits
DescriptionLimit
Dynamic sources in a JSON template100
Dynamic sources in general theme settings100
Dynamic sources in a section group100
Dynamic sources in a single setting50
Dynamic sources in a static section50

Was this page helpful?