Creating custom metafield definitions
If there's no standard metafield definition for the specialized information that you want to add to your Shopify store, then you can create a custom metafield definition. You also create custom definitions when you migrate existing metafields to a definition.
When you create a custom definition for a metafield, you specify the following information:
- Name: used to identify the metafield in your Shopify admin, such as
Color. - Type: the type of data that the metafield stores. You select a type from a searchable list of categories and presets, such as single-line text, file, or URL.
- Namespace and key: the unique identifier for your metafield, which is automatically generated from the name. You can use a namespace to group similar metafields together, but each namespace and key must be unique. An example is
custom.color. - Description (optional): allows you to include descriptive information, such as what values to enter for the metafield.
- Validations (optional): the rules for the input of the values, such as character limits, or minimum and maximum values.
On this page
Before you begin
Before you create a custom metafield definition, review the following information to make sure that you understand how to configure your definition:
Create a custom definition
From your Shopify admin, go to Settings > Metafields and metaobjects.
Select the part of your store that you want to add a metafield to. For example, Products.
Click Add definition.
In the Name field, enter a name for your definition. If a matching standard definition appears as a suggestion below the field, then you can click it to use the standard definition instead.
Optional: In the Namespace and key field, edit the automatically generated identifier for your metafield.
Click Select type, and then search for or select the type that best matches your metafield from the list. Types are organized into categories with presets, such as Single line text or File > Image. For more information about available types, refer to metafield content types and values.
Optional: To allow a list of values in your metafield, click One value and then select List of values.
Optional: Click Add description to enter a description for your metafield values.
Optional: If a Validation section appears below the definition, then configure the validation rules to limit the range of accepted values for your metafield. The available validation options depend on the type that you selected.
Optional: To allow custom storefronts to display values for this metafield, select Storefronts.
Optional: To allow for this definition to display for smart collections, select Smart collections. This option is only available for product and variant metafields.
Optional: Click Definition pinned to unpin the metafield so that the corresponding pages in your Shopify admin don't automatically display the metafield.
Click Save.
Next steps after adding metafield definitions
After you add definitions for your metafields, you can complete the following actions:
- Pin or unpin metafield definitions to determine the order in which your metafields are displayed.
- Add values to metafields for parts of your store.
- Connect your metafields to your theme to display them on your online store.
Using custom metafields with the Storefront API
If you want to allow custom storefronts to display your metafields, then you can give access to the Storefront API when you create or edit a metafield definition. If you sell your Shopify products through a non-Shopify website, video game, or other custom shopping experience, then you might want to give access to the Storefront API.
By default, values for custom metafields aren't accessible to custom storefronts. Learn more about using metafields with the Storefront API.