Populate a field with meta tag content

Recording metadata with your indexed items in the Coveo Platform is a three-step process:

  1. Extracting a piece of metadata from your content.

  2. Creating a field.

  3. Creating a mapping rule to index the piece of metadata in that field.

A Web source automatically collects some metadata for you (that is, step 1). Knowing which metadata is automatically extracted can spare you from doing the first step needlessly.

Note

You need to set up a web scraping configuration to extract metadata yourself.

Automatically extracted metadata

The HTML content attribute of <meta> tags is extracted when the tag is keyed with one of the following attributes: name, property, itemprop, or http-equiv.

Example

The HTML of a web page contains <meta name="viewport" content="width=device-width, initial-scale=1.0" /> in its <head> section. When the Web source indexes this page, it automatically extracts a viewport metadata whose value is width=device-width, initial-scale=1.0.

Tip

The View metadata feature lets you see all the metadata currently extracted from your content, whether indexed (that is, mapped to a field) or not.

View metadata feature showing mapped and unmapped metadata | Coveo

Store <meta> tag metadata in a field

If you have the necessary privileges, you can store an automatically extracted <meta> tag metadata with your indexed items as follows:

  1. On the Fields (platform-ca | platform-eu | platform-au) page, click Add field.

  2. In the Add a field panel, provide a field name. Specify other field settings as necessary.

    Adding a field called description
  3. In the Sources (platform-ca | platform-eu | platform-au) page, click your source, and then click More > Manage mappings in the Action bar.

  4. In the Edit the mappings of a source panel, click Add > Mapping.

  5. In the Apply a mapping on all item types of a source panel, create a mapping rule which specifies the name of the metadata to be used to populate the field. Click Apply mapping when you’re done.

    Adding the mapping for the description field
    Notes
  6. Rebuild your Web source.

  7. Inspect a few items in the Content Browser to make sure that the field is properly populated.

What’s next?

Use your field in an Atomic search interface as follows:

  • Add your field to the fieldsToInclude property of the atomic-search-interface component.

  • Use your field in a atomic-field-condition component. For example, you can create a condition to display the field value in search results only when the item has a value for that field.

  • Use the type-specific Atomic result component to display your field values in search results (for example, atomic-result-text, atomic-result-number).

Tip

See the code sample of the atomic-result-fields-list interactive example.