# dirname

**Kind:** Function

**Source:** [`src/helper/ssg/utils.ts`](https://github.com/honojs/hono/blob/main/src/helper/ssg/utils.ts#L11)

**Part of:** [Helper](subsystem-src-helper)

Get dirname

`dirname` gets the directory portion of a file or path string. It supports static-site-generation helpers that need to locate a file's parent directory before resolving related paths or writing output.

## Signature

```ts
function dirname(path: string): string
```

## Parameters

| Name | Type |
|---|---|
| `path` | `string` |

**Returns:** `string`

## Diagram

```mermaid
graph LR
  A[Path string] --> B[dirname]
  B --> C[Directory path]
```

## Usage

```ts
import { dirname } from '../src/helper/ssg/utils'

const filePath = 'content/guides/setup.mdx'
const directory = dirname(filePath)

console.log(directory)
```

## AI Coding Instructions

- Pass a path string representing a file or nested resource.
- Use the returned directory path when resolving files relative to the current resource.
- Keep path-format handling consistent with other SSG utilities.
- Check callers that may pass root-level paths or paths without directory segments.

## Relationships

- IMPORTS → `METHOD_NAME_ALL`
- IMPORTS → `findTargetHandler`
- IMPORTS → `isMiddleware`

## Used by

1 reference from 1 file. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (1)

- `DEFAULT_OUTPUT_DIR` — `src/helper/ssg/ssg.ts`:27
