---
title: "cb:assetPath"
manual: "Content Blocks"
version: "main"
permalink: "https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:content-blocks-view-helper-asset-path@main"
source: "Templating/ViewHelpers/AssetPath/Index.rst"
rendered: "2026-09-22T14:15:39+00:00"
---

# cb:assetPath {#content-blocks-view-helper-asset-path}

-   Class: `\TYPO3\CMS\ContentBlocks\ViewHelpers\AssetPathViewHelper`

Resolves the public path to the `assets` directory of a Content Block.
Use it together with the Core `f:asset.css` and `f:asset.script`
ViewHelpers to include CSS and JavaScript files, which are shipped inside the
Content Block itself.

> [!WARNING]
> This ViewHelper only works inside the template of a Content Block. It
> resolves the current Content Block via the `data._name` or
> `settings._content_block_name` template variable. If neither
> variable is available (for example when called from a partial rendered
> completely outside of a Content Block context) and `name` is not
> given explicitly, an exception is thrown.

## Arguments {#arguments}

-   **name**

    -   *Type:* string

    The target Content Block name (`vendor/name`). If not set, the
    current Content Block is resolved automatically.

## Examples {#examples}

### Default usage {#default-usage}

Inside the current Content Block's own template, `name` can be omitted.
The current Content Block is detected automatically.

```html
<f:asset.css identifier="myCssIdentifier" href="{cb:assetPath()}/frontend.css"/>
<f:asset.script identifier="myJavascriptIdentifier" src="{cb:assetPath()}/frontend.js"/>
```

### Explicit Content Block name {#explicit-content-block-name}

You can also point to the assets of a different Content Block by setting
`name` explicitly.

```html
<f:asset.script identifier="myJavascriptIdentifier" src="{cb:assetPath(name: 'vendor/name')}/frontend.js"/>
```

## See also {#see-also}

-   [Asset ViewHelpers](https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:asset-view-helpers@main)
-   [Assets definition](https://docs.typo3.org/permalink/friendsoftypo3/content-blocks:cb-definition-assets@main)
