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.
  • Namespace and key: the unique identifier for your metafield. 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
  • Type: the type of data that the metafield stores, such as text, file, or URL.
  • Validations (optional): the rules for the input of the values, such as character limits, or minimum and maximum values.s

Some content types have additional configuration options that you need to select. Configuration options can include the following:

  • default units of measurement
  • single-line or multi-line fields
  • minimum and maximum values
  • default currency

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

  1. From your Shopify admin, go to Settings > Custom data.
  2. Select the part of your store that you want to add a metafield to. For example, Products.
  3. Click Add definition.
  4. In the Name field, enter a name for your definition, and then select the name that you entered from the list.
  5. Optional: In the Namespace and key field, edit the default identifier for your metafield.
  6. Optional: In the Description field, enter a description for your metafield values.
  7. Optional: To allow custom storefronts to display values for this metafield, select Storefronts.
  8. Optional: To allow for this definition to display for automated collections, select Automated collections. This option is only available for product and variant metafields.
  9. Click Select content type, and then select the content type that best matches your metafield from the list.
  10. Optional: To allow a list of values in your metafield, select Accept list of values.
  11. Configure the content type and validation information:
    • If the content type has additional configuration options, then select the correct option for your metafield. For example, type of measurement.
    • Optional: In the Validation section, configure the Additional rules to limit the range of accepted values.
    • Optional: To change the content type or validation rules for your custom definition, click Change, and then select another content type from the list.
  12. Optional: Click Definition pinned to unpin the metafield so that the corresponding pages in your Shopify admin don't automatically display the metafield,
  13. Click Save.

Next steps after adding metafield definitions

After you add definitions for your metafields, you can complete the following actions:

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.

Ready to start selling with Shopify?Try it free