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:
- namespace and key, for example, to group metafields for specific parts of your store
- content type, such as text, file, or URL
- validation rules, such as character limits, or minimum and maximum values
- description (optional), such as information about what values to enter for the metafield
Learn more about parts of a metafield definition.
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
Create a custom definition
- From your Shopify admin, go to Settings > Metafields.
- In the Manage metafields section, select the type of metafield that you want to add. For example, Product metafields.
- Click Add metafield definition.
- In the Name field, enter a name for your definition, and then select the name that you entered from the dropdown menu.
- Optional: In the Namespace and key field, edit the default identifier for your metafield.
- Optional: In the Description field, enter a description for your metafield values.
- Click Select content type, and then select the content type that best matches your metafield from the dropdown menu.
- 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.
- If the content type has a Defaults section, then select a default unit from the dropdown menu.
- Optional: If you want to change the content type or validation rules for your custom definition, click Change, and then select another content type from the dropdown menu.
- Click Save.
After you add definitions for your metafields, you can do the following: