--- title: "Liquid filters: metafield_tag" description: |- Generates an HTML element to host the data from a [`metafield` object](https://shopify.dev/docs/api/liquid/objects/metafield). The type of element that's generated differs depending on the type of metafield. api_name: liquid source_url: html: https://shopify.dev/docs/api/liquid/filters/metafield_tag md: https://shopify.dev/docs/api/liquid/filters/metafield_tag.md --- # metafield\_​tag ```oobleck metafield | metafield_tag ``` returns [string](https://shopify.dev/docs/api/liquid/basics#string) Generates an HTML element to host the data from a [`metafield` object](https://shopify.dev/docs/api/liquid/objects/metafield). The type of element that's generated differs depending on the type of metafield. *** Note The `metafield_tag` filter doesn't currently support list metafields other than `list.single_line_text_field` and `list.metaobject_reference`. *** ### Basic types Most metafield types return a simple HTML element: | Type | Element | Attributes | | - | - | - | | `boolean` | `` | `class="metafield-boolean"` | | `collection_reference` | `` | `class="metafield-collection_reference"` | | `color` | `` | `class="metafield-color"` | | `date` | `Potion dosages Dried chamomile 4.5 Take with a meal. www.canada.ca/en/health-canada/services/food-nutrition/legislation-guidelines/acts-regulations/canada-food-drugs.html S / Medium

Are you low on health? Well we've got the potion just for you!

Just need a top up? Almost dead? In between? No need to worry because we have a range of sizes and strengths!

``` ### Complex types The following metafield types return nested elements, or different elements depending on the metafield contents: * [`dimension`](https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-dimension) * [`file_reference`](https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-file_reference) * [`list.metaobject_reference`](https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-list.metaobject_reference) * [`list.single_line_text_field`](https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-list.single_line_text_field) * [`metaobject_reference`](https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-metaobject_reference) * [`volume`](https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-volume) * [`weight`](https://shopify.dev/docs/api/liquid/filters/metafield_tag#metafield_tag-weight) ### dimension Outputs a `` element with the following attribute: | Attribute | Value | | - | - | | `class` | `metafield-dimension` | The `` element contains the following child elements: | Child element | HTML element | Attributes | | - | - | - | | The dimension value. If it's a decimal with more than two places, then it'll be formatted to have a precision of two with trailing zeros removed. | `` | `class="metafield-dimension_value"` | | The dimension unit. | `` | `class="metafield-dimension_unit"` | ##### Code ```liquid {{ product.metafields.details.scale_width | metafield_tag }} ``` ##### Data ```json { "product": { "metafields": {} } } ``` ##### Output ```html 3 cm ``` ### file\_reference The output varies depending on the type of file. There are the following categories of file type: | File type | Description | | - | - | | Image | Images in the format of `jpg`, `png`, `gif`, `heic`, and `webp`. | | Video | Videos in the format of `mov`, and `mp4`. | | Other | Any other file type. | ##### Image Outputs an `` element with the following attributes: | Attribute | Value | | - | - | | `src` | The image's URL. | | `alt` | The image's alt text. | | `class` | `metafield-file_reference` | ##### Video Outputs a `