Migrating metafields
If you want to add validation rules to an existing set of metafields, then you can migrate your unstructured metafields to a definition. When you create a custom definition for existing sets of metafields, the validation rules that you specify prevent you or your apps from adding invalid values.
You migrate your unstructured metafields by creating a custom definition for a set of metafields with a particular namespace and key. For more information about creating custom definitions, refer to the following resources:
On this page
Considerations for unstructured metafields
- You can only add definitions for sets of metafields that have a namespace and key with the correct format. If your namespace and key contains special characters, then you can't migrate that set of metafields to a definition.
- If any metafield values don't match your new definition, then you need to fix your metafield values.
Create a definition for an unstructured metafield
From your Shopify admin, go to Settings > Metafields and metaobjects.
Select the part of your store that you want to add a metafield definition for. For example, Products.
Click View unstructured metafields or, if you have other options available, then click More actions > View unstructured metafields. If View unstructured metafields isn't available, then that part of your store doesn't have unstructured metafields.
Click Add definition next to the namespace and key that you want to add a definition for.
If the namespace and key doesn't match a standard definition, then enter the following information for your metafield definition:
- In the Name field, enter a name for your definition.
- Optional: In the Description field, enter a description for your metafield.
Click Select type, and then select the content type that best matches your metafield values from the list.
Configure the content type and validation information by doing the following:
- In the Validations section, configure the additional rules for your definition.
- If the content type has additional configuration options, then enable your preferred options.
Click Save.
Review the validation results, and then click Save definition.
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.