# Reuse markup with includes and categories

Source: https://zotonic.com/docs/2943/reuse-markup-with-includes-and-categories

URI: https://zotonic.com/id/2943

Language: en

Extract repeated markup into a partial and pass its inputs explicitly.

```django
{% include "_garden_card.tpl" id=id %}
```

Inside the partial, read the resource using `m.rsc[id]`. Keep the partial focused on one component so another page can reuse it without inheriting unrelated page behavior.

Use a category include when the representation depends on the resource's category:

```django
{% catinclude "_garden_card.tpl" id %}
```

Provide a generic fallback and add category-specific variants when their markup differs. Use the template selection tools to check which variant wins for the resource. See <a href="/id/1326" class="doc-reference doc-reference-tag"><code>tag#include</code></a>, <a href="/id/1325" class="doc-reference doc-reference-tag"><code>tag#catinclude</code></a>, and [Find the template used by a page](/id/2941).

For the example above, save the fallback as `priv/templates/_garden_card.tpl`. An event-specific version is `_garden_card.event.tpl`. A resource named `garden_open_day` can override both with `_garden_card.name.garden_open_day.tpl`. Test an event and an ordinary text resource: the latter should still use the fallback.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2943?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2943?language=en>)
