Metafield definitions

Metafield definitions act as templates that specify what part of your store a metafield applies to and what values the metafield can have. Before you can add metafield values to specific products, orders, or other parts of your store, you first need to add the metafield definition for that information. Adding metafield definitions ensures that the same validation rules apply to every value that you enter for a specific metafield.

You can add metafield definitions on the Metafields page of your Shopify admin. Additional types of metafields can be added by using an app from the Shopify App Store or by editing your theme code. You can have up to 100 metafield definitions.

Parts of a metafield definition

Metafield definitions have the following parts:

Parts of a metafield definition
Name Description
Namespace and key

Together, the namespace and key create a unique identifier for your metafield. They're separated by a ., and can only contain letters, numbers, _, and -.

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.

Standard definitions use standardized namespaces and keys, while custom definitions use automatically generated namespaces and keys that you can edit. Learn more about types of metafield definitions.

Value The type and format of information that's contained in your metafield. For example, plain text, URL, or integer.
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.

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 2021/07/01 and 2025/12/31 are valid.

For more information, refer to the developer documentation for metafields.

Types of metafield definitions

When you add a metafield definition, you can do either of the following:

  • Select a standard definition.
  • Create a custom definition.

Whenever possible, use a standard definition for your metafields. Standard definitions are automatically configured for you, and are designed to be universally compatible across Shopify. Because standard metafield definitions follow standards that are used across all Shopify stores, they're supported by apps, themes, and other parts of your store. Some examples of standard definitions include product rating, date and time, and related products. For more information about standard definitions, refer to Shopify standard metafields.

You need to create a custom definition in the following circumstances:

Ready to start selling with Shopify?

Try it free