Parts of a metafield definition
Metafield definitions specify which part of your store a metafield applies to and what values the metafield can have. Make sure that you understand the parts of a metafield definition before you do you the following tasks:
Metafield definitions have the following parts:
- name, which is used to identify the metafield in your Shopify admin
- key, for example, to group metafields for specific parts of your store
- description (optional), such as information about what values to enter for the metafield
- type, such as text, file, or URL
- validations (optional), such as character limits, or minimum and maximum values
For example, a metafield definition for product expiration date might have the key ofproducts.expiration_date
, a value ofDate, and a description ofEnter the date in the format YYYY/MM/DD. Its validations might specify that only date values between2021/07/01
and2025/12/31
are valid.
For more information about the parts of a metafield definition, refer to the following table or reviewthe developer documentation for Metafields.
Name | Description |
---|---|
Namespace and key | Together, the namespace and key create a unique identifier for your metafield. They're separated by a You can use a namespace to group similar metafields together, but each namespace and key combination must be unique. For example, you can use the namespaceproductsto group the keysexpiration_dateandratingfor your product metafields. Standard definitionsuse standardized namespaces and keys, whilecustom definitionsuse automatically generated namespaces and keys that you can edit. |
Value | The type and format of information that's contained in your metafield. For example, plain text, URL, or integer. Metafields can only accept the supported values for their content type. For more information about supported values for common types of metafields, refer toMetafield content types and values. |
Description (optional) | An description of the metafield to help you input the correct values. The description is displayed on the Shopify admin page where you add values for your metafield. |
Validation (optional) | A setting that you can configure to limit the values that your metafield can contain. You can set minimum and maximum values, or use regular expressions to control the range of accepted values for your metafield. |