Parts of a metafield definition
Metafield definitions specify what 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:
- namespace and key, for example, to group metafields for specific parts of your store
- content type, such as text, file, or URL
- validation rules (optional), such as character limits, or minimum and maximum values
- description (optional), such as information about what values to enter for the metafield
For example, a metafield definition for product expiration date might have the namespace and key of
products.expiration_date, a value of Date, and a description of Enter the date in the format YYYY/MM/DD. Its validation rules might specify that only date values between
2025/12/31 are valid.
For more information about the parts of a metafield definition, refer to the following table or review the developer documentation for Metafields.
|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 namespace products to group the keys expiration_date and rating for your product metafields.
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 to Metafield 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.|