> ## Content Index
> Fetch the complete content index at: https://getpublii.com/dev/llms.txt
> Use this file to discover other available public pages before exploring further.

# Creating custom partials

- URL: https://getpublii.com/dev/creating-custom-partials/
- Published: 2017-08-04T22:39:13.511Z
- Updated: 2024-02-08T09:36:48.966Z
- Description: Theme developers can create custom partials in their themes. It is handy if you want to reuse your code in many views. To create a…
- Author: Tomasz Dziuda
- Tags: Partials

Theme developers can create custom partials in their themes. It is handy if you want to reuse your code in many views.

To create a custom partial just create a **\*.hbs** file in the theme partials directory. The name of the partial file will be used in the theme code.

E.g., if you create **partials/cookiebar.hbs** file in your theme, then you can use it in other files as:

```handlebars
{{> cookiebar}}
```

It is also possible to create partials which have params - this is especially useful when you have problems with context.

Let's analyze the following situation:

We have the following context for a view:

```json
{
    config: {
        optionValue: true
    },
    pages: [
       { title: "Lorem" },
       { title: "Ipsum" }
    ]
}
```

And we load our partial in the main file as follows:

```handlebars
{{#each pages}}
    {{> page}}
{{/each}}
```

We can access `{{title}}` in our partial, but `{{config}}` is unavailable even if we use `{{../config}}`.

The solution is creating a param for our partial:

```handlebars
{{#each pages}}
    {{> page config=../config}}
{{/each}}
```

In the above example, we will be able to access `{{config}}` in our partial.
