# block

Source: https://zotonic.com/docs/1346/block

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

Language: en



::: {.aside}
See also

<a href="/id/doc_template_tag_tag_extends" class="doc-reference doc-reference-tag"><code>tag#extends</code></a> and <a href="/id/doc_template_tag_tag_overrules" class="doc-reference doc-reference-tag"><code>tag#overrules</code></a>.
:::

Define a template block and overrules a template block from an inherited template.

The block tag is used for replacing template blocks in inherited templates.

For example, when we have a template base.tpl, in which we define a template block called name:

```django
Hello {% block name %}my{% endblock %} world.
```

And we define a second template, page.tpl, which uses <a href="/id/doc_template_tag_tag_extends" class="doc-reference doc-reference-tag"><code>tag#extends</code></a> to extend the first template:

```django
{% extends "base.tpl" %}
{% block name %}Peter's{% endblock %}
```

Then the result of rendering page.tpl will be:

```django
Hello Peter's world.
```

If we do not include the template block definition, so page.tpl just contains the <a href="/id/doc_template_tag_tag_extends" class="doc-reference doc-reference-tag"><code>tag#extends</code></a> tag:

```django
{% extends "base.tpl" %}
```

then the output will be:

```django
Hello my world.
```

The name of a template block must be a valid identifier, consisting of alphanumeric characters (a-z, 0-9) and the underscore charater.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1346?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/1346?language=en>)
