---
title: "tags:beforeResolve Hook"
description: "First synchronous hook over the normalized, deduplicated tag set."
canonical_url: "https://unhead.unjs.io/docs/head/api/hooks/tags-before-resolve"
last_updated: "2026-08-11T00:41:12.368Z"
---

The `tags:beforeResolve` hook is the first of three synchronous `tags:*` hooks. It runs after entry normalization, weighting, deduplication, title-template resolution, and conversion of the deduplication map back into `ctx.tags`.

## Hook Signature

```ts
export interface Hook {
  'tags:beforeResolve': (ctx: TagResolveContext) => SyncHookResult
}

interface TagResolveContext {
  tagMap: Map<string, HeadTag>
  tags: HeadTag[]
}
```

### Parameters

<table>
<thead>
  <tr>
    <th>
      Name
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ctx.tags
      </code>
    </td>
    
    <td>
      <code>
        HeadTag[]
      </code>
    </td>
    
    <td>
      Current deduplicated tag array
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ctx.tagMap
      </code>
    </td>
    
    <td>
      <code>
        Map<string, HeadTag>
      </code>
    </td>
    
    <td>
      Deduplication lookup built by the resolver
    </td>
  </tr>
</tbody>
</table>

This hook is synchronous. Mutate or replace `ctx.tags` to change the tags that continue through resolution. Adding or deleting a `tagMap` entry alone does not rebuild `ctx.tags`.

Prefer `ctx.tags` when walking the complete result. Arrayable meta groups may use an array-like aggregate in `tagMap` at runtime even though the public lookup type is `Map<string, HeadTag>`.

## Usage Example

```ts
import { defineHeadPlugin } from '@unhead/dynamic-import/plugins'

export const markExternalScriptsPlugin = defineHeadPlugin({
  key: 'mark-external-scripts',
  hooks: {
    'tags:beforeResolve': ({ tags }) => {
      for (const tag of tags) {
        if (tag.tag === 'script' && /^https?:\/\//.test(tag.props.src))
          tag.props['data-external'] = ''
      }
    }
  }
})
```
