---
title: "entries:resolve Hook · v2 · Unhead"
meta:
  "og:description": "Learn about the entries:resolve hook in Unhead that processes entries before they're converted to tags"
  "og:title": "entries:resolve Hook · v2 · Unhead"
  description: "Learn about the entries:resolve hook in Unhead that processes entries before they're converted to tags"
---

**Hooks**

# **entries:resolve Hook**

**On this page **

- [Lifecycle Position](#lifecycle-position)
- [Hook Signature](#hook-signature)
- [Usage Example](#usage-example)
- [Use Cases](#use-cases)

The `entries:resolve` hook is called when head entries need to be resolved into tags. This hook provides access to both the entries and the tags being generated, allowing you to modify or add to the collection before the final tag resolution process.

## [Lifecycle Position](#lifecycle-position)

This hook runs after [`entries:updated`](https://unhead.unjs.io/docs/v2/head/api/hooks/entries-updated) and before [`entries:normalize`](https://unhead.unjs.io/docs/v2/head/api/hooks/entries-normalize).

## [Hook Signature](#hook-signature)

```
export interface Hook {
  'entries:resolve': (ctx: EntryResolveCtx<any>) => HookResult
}
```

### [Parameters](#parameters)

| **Name** | **Type** | **Description** |
| --- | --- | --- |
| `ctx` | `EntryResolveCtx<any>` | Context containing the entries and tags being processed |

The `EntryResolveCtx` interface is defined as:

```
interface EntryResolveCtx<T> {
  tags: HeadTag[]
  entries: HeadEntry<T>[]
}
```

### [Returns](#returns)

`HookResult` which is either `void` or `Promise<void>`

## [Usage Example](#usage-example)

```
import { createHead } from '#imports'

const head = createHead({
  hooks: {
    'entries:resolve': (ctx) => {
      // Inspect the entries being processed
      console.log(\`Processing ${ctx.entries.length} head entries\`)

      // You can modify or add to the tags collection
      ctx.tags.push({
        tag: 'meta',
        props: {
          name: 'generator',
          content: 'Unhead'
        }
      })
    }
  }
})
```

## [Use Cases](#use-cases)

### [Adding Global Meta Tags](#adding-global-meta-tags)

Use this hook to add global meta tags that should be present on all pages:

```
import { defineHeadPlugin } from '#imports'

export const globalMetaPlugin = defineHeadPlugin({
  hooks: {
    'entries:resolve': (ctx) => {
      // Add global meta tags
      ctx.tags.push(
        {
          tag: 'meta',
          props: {
            name: 'author',
            content: 'Your Company'
          }
        },
        {
          tag: 'meta',
          props: {
            property: 'og:site_name',
            content: 'Your Application'
          }
        }
      )
    }
  }
})
```

### [Extracting Information from Entries](#extracting-information-from-entries)

You can use this hook to extract and process information from entries:

```
import { defineHeadPlugin } from '#imports'

export const analyticsDataPlugin = defineHeadPlugin({
  hooks: {
    'entries:resolve': (ctx) => {
      // Extract all page titles and descriptions for analytics
      const pageData = ctx.entries.reduce((acc, entry) => {
        const input = entry.input
        if (typeof input === 'object') {
          if ('title' in input) {
            acc.title = input.title
          }

          if ('meta' in input && Array.isArray(input.meta)) {
            const descMeta = input.meta.find(m =>
              m.name === 'description' || m.property === 'og:description'
            )
            if (descMeta) {
              acc.description = descMeta.content
            }
          }
        }
        return acc
      }, {})

      // Use the extracted data
      if (!ctx.entries[0].options.ssr) {
        logPageView(pageData)
      }
    }
  }
})

function logPageView(data) {
  // Send data to analytics service
  console.log('Logging page view:', data)
}
```

[Edit this page](https://github.com/unjs/unhead/edit/v2.1.2/docs/v2/head/7.api/hooks/03.entries-resolve.md)

**Did this page help you? **

[**entries:updated** Learn about the entries:updated hook in Unhead that's triggered when head entries are modified](https://unhead.unjs.io/docs/v2/head/api/hooks/entries-updated) [**entries:normalize** Learn about the entries:normalize hook in Unhead that processes each entry before converting it to tags](https://unhead.unjs.io/docs/v2/head/api/hooks/entries-normalize)

**On this page **

- [Lifecycle Position](#lifecycle-position)
- [Hook Signature](#hook-signature)
- [Usage Example](#usage-example)
- [Use Cases](#use-cases)