{"result":{"depiction_url":null,"edges":{"hasreference":{"objects":[{"created":"2026-10-07T11:13:49Z","object_id":{"id":2942,"is_a":["text","documentation","developerguide"],"name":"developer_template_layout","title":{"_type":"trans","tr":{"en":"Create a page layout"}},"uri":"https:\/\/zotonic.com\/id\/2942"},"seq":1},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2943,"is_a":["text","documentation","developerguide"],"name":"developer_template_components","title":{"_type":"trans","tr":{"en":"Reuse markup with includes and categories"}},"uri":"https:\/\/zotonic.com\/id\/2943"},"seq":2},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2325,"is_a":["text","documentation","cookbook"],"name":null,"title":{"_type":"trans","tr":{"en":"Render template values safely"}},"uri":"https:\/\/zotonic.com\/id\/2325"},"seq":3},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2946,"is_a":["text","documentation","developerguide"],"name":"developer_template_cache","title":{"_type":"trans","tr":{"en":"Cache a template fragment"}},"uri":"https:\/\/zotonic.com\/id\/2946"},"seq":4}],"predicate":{"id":2774,"is_a":["meta","predicate"],"name":"hasreference","title":{"_type":"trans","tr":{"en":"Documentation reference"}},"uri":"https:\/\/zotonic.com\/id\/hasreference"}},"references":{"objects":[{"created":"2020-05-30T05:47:41Z","object_id":{"id":1540,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_controllers","title":{"_type":"trans","tr":{"en":"Add an HTTP controller"}},"uri":"https:\/\/zotonic.com\/id\/1540"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1840,"is_a":["text","documentation","reference"],"name":"doc_reference_global_variables","title":"Global template variables","uri":"https:\/\/zotonic.com\/id\/1840"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1388,"is_a":["text","documentation","reference","template_scomp"],"name":"doc_template_scomp_scomp_debug","title":"debug","uri":"https:\/\/zotonic.com\/id\/1388"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":325,"is_a":["meta","category"],"name":"template_filter","title":"Filters","uri":"https:\/\/test.zotonic.com\/id\/325"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1572,"is_a":["text","documentation","cookbook"],"name":"doc_cookbook_custom_filter","title":{"_type":"trans","tr":{"en":"Add a filter or rendering component"}},"uri":"https:\/\/zotonic.com\/id\/1572"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":324,"is_a":["meta","category"],"name":"template_tag","title":"Tags","uri":"https:\/\/test.zotonic.com\/id\/324"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1574,"is_a":["text","documentation","cookbook"],"name":"doc_cookbook_custom_tag","title":{"_type":"trans","tr":{"en":"Create a custom template tag"}},"uri":"https:\/\/zotonic.com\/id\/1574"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1860,"is_a":["text","documentation","developerguide"],"name":"doc_bestpractices_templates","title":{"_type":"trans","tr":{"en":"Reuse markup with includes and categories"}},"uri":"https:\/\/zotonic.com\/id\/1860"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":322,"is_a":["meta","category"],"name":"model","title":"Models","uri":"https:\/\/test.zotonic.com\/id\/322"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1573,"is_a":["text","documentation","cookbook"],"name":"doc_cookbook_custom_model","title":{"_type":"trans","tr":{"en":"Expose data through a model"}},"uri":"https:\/\/zotonic.com\/id\/1573"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1527,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_sites","title":{"_type":"trans","tr":{"en":"Create your first site"}},"uri":"https:\/\/zotonic.com\/id\/1527"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1353,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_modules","title":{"_type":"trans","tr":{"en":"Create a reusable module"}},"uri":"https:\/\/zotonic.com\/id\/1353"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1355,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_all_include","title":"all_include","uri":"https:\/\/zotonic.com\/id\/1355"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1354,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_all_catinclude","title":"all_catinclude","uri":"https:\/\/zotonic.com\/id\/1354"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1277,"is_a":["text","documentation","userguide"],"name":"doc_userguide_datamodel","title":{"_type":"trans","tr":{"en":"Understand pages and connections"}},"uri":"https:\/\/zotonic.com\/id\/1277"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1534,"is_a":["text","documentation","reference","controller"],"name":"doc_controller_controller_page","title":"controller_page","uri":"https:\/\/zotonic.com\/id\/1534"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1278,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_rsc","title":"rsc","uri":"https:\/\/zotonic.com\/id\/1278"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1276,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_resources","title":{"_type":"trans","tr":{"en":"Use stable resource names"}},"uri":"https:\/\/zotonic.com\/id\/1276"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1325,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_catinclude","title":"catinclude","uri":"https:\/\/zotonic.com\/id\/1325"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1326,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_include","title":"include","uri":"https:\/\/zotonic.com\/id\/1326"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1347,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_extends","title":"extends","uri":"https:\/\/zotonic.com\/id\/1347"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1346,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_block","title":"block","uri":"https:\/\/zotonic.com\/id\/1346"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1370,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_inherit","title":"inherit","uri":"https:\/\/zotonic.com\/id\/1370"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1348,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_overrules","title":"overrules","uri":"https:\/\/zotonic.com\/id\/1348"},"seq":1000000}],"predicate":{"id":332,"is_a":["meta","predicate"],"name":"references","title":{"_type":"trans","tr":{"en":"References"}},"uri":"https:\/\/zotonic.com\/id\/references"}},"refers":{"objects":[{"created":"2026-10-07T11:13:00Z","object_id":{"id":1325,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_catinclude","title":"catinclude","uri":"https:\/\/zotonic.com\/id\/1325"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":1326,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_include","title":"include","uri":"https:\/\/zotonic.com\/id\/1326"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":1355,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_all_include","title":"all_include","uri":"https:\/\/zotonic.com\/id\/1355"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":1357,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_cache","title":"cache","uri":"https:\/\/zotonic.com\/id\/1357"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":1461,"is_a":["text","documentation","reference","template_filter"],"name":"doc_template_filter_filter_escape","title":"escape","uri":"https:\/\/zotonic.com\/id\/1461"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":1536,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_access_control","title":{"_type":"trans","tr":{"en":"Keep permission checks at the boundary"}},"uri":"https:\/\/zotonic.com\/id\/1536"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":2941,"is_a":["text","documentation","developerguide"],"name":"developer_template_selection","title":{"_type":"trans","tr":{"en":"Find the template used by a page"}},"uri":"https:\/\/zotonic.com\/id\/2941"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":2960,"is_a":["text","documentation","developerguide"],"name":"developer_model_api","title":{"_type":"trans","tr":{"en":"Expose data through a model"}},"uri":"https:\/\/zotonic.com\/id\/2960"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":2979,"is_a":["text","documentation","developerguide"],"name":"developer_cache_debugging","title":{"_type":"trans","tr":{"en":"Distinguish stale cache data from stale code"}},"uri":"https:\/\/zotonic.com\/id\/2979"},"seq":1000000},{"created":"2026-10-07T11:13:00Z","object_id":{"id":2983,"is_a":["text","documentation","developerguide"],"name":"developer_testing_strategy","title":{"_type":"trans","tr":{"en":"Choose checks for a change"}},"uri":"https:\/\/zotonic.com\/id\/2983"},"seq":1000000}],"predicate":{"id":2409,"is_a":["meta","predicate"],"name":"refers","title":{"_type":"trans","tr":{"en":"Refers"}},"uri":"https:\/\/zotonic.com\/id\/refers"}},"relation":{"objects":[{"created":"2020-05-30T05:47:41Z","object_id":{"id":1280,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_media","title":{"_type":"trans","tr":{"en":"Render and manage media"}},"uri":"https:\/\/zotonic.com\/id\/1280"},"seq":1000000},{"created":"2020-05-30T05:47:41Z","object_id":{"id":1539,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_wires","title":{"_type":"trans","tr":{"en":"Handle a browser event with a wire"}},"uri":"https:\/\/zotonic.com\/id\/1539"},"seq":1000000}],"predicate":{"id":303,"is_a":["meta","predicate"],"name":"relation","title":{"_type":"trans","tr":{"nl":"Relatie","en":"Relation"}},"uri":"http:\/\/purl.org\/dc\/terms\/relation"}},"subject":{"objects":[{"created":"2026-10-07T11:13:49Z","object_id":{"id":2554,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_how_to_guide","title":"How-to guide","uri":"https:\/\/zotonic.com\/id\/2554"},"seq":1},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2620,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template","title":"Template","uri":"https:\/\/zotonic.com\/id\/2620"},"seq":3},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2641,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_render","title":"Render","uri":"https:\/\/zotonic.com\/id\/2641"},"seq":4},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2685,"is_a":["categorization","keyword","keyword_quality"],"name":"zotonic_topic_security","title":"Security","uri":"https:\/\/zotonic.com\/id\/2685"},"seq":5},{"created":"2026-10-07T11:13:49Z","object_id":{"id":2630,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_cache","title":"Cache","uri":"https:\/\/zotonic.com\/id\/2630"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1352,"is_a":["text","documentation","developerguide"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1352"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_developerguide_templates","page_url":{"en":"https:\/\/zotonic.com\/docs\/1352\/create-a-page-layout","x-default":"https:\/\/zotonic.com\/docs\/1352\/create-a-page-layout"},"preview_url":null,"resource":{"version":53,"pivot_location_lat":null,"title":{"_type":"trans","tr":{"en":"Create a page layout"}},"is_authoritative":true,"body":{"_type":"trans","tr":{"en":"<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% extends &quot;base.tpl&quot; %}\n{% block content %}\n&lt;main&gt;\n    &lt;h1&gt;{_ Our garden _}&lt;\/h1&gt;\n    &lt;p&gt;{_ Find out what is growing this week. _}&lt;\/p&gt;\n&lt;\/main&gt;\n{% endblock %}\n<\/code><\/pre>\n<p>Check which blocks your chosen base provides before overriding one. Keep the standard head and body includes so active modules can contribute scripts, styles, metadata, and browser initialization. In a custom base, use <a href=\"\/id\/1355\" class=\"doc-reference doc-reference-tag\"><code>tag#all_include<\/code><\/a> with the standard include names instead of copying module-specific head fragments.<\/p>\n<p>In a custom base, put <code>{% all include &quot;_html_head.tpl&quot; %}<\/code> inside <code>&lt;head&gt;<\/code>. Near the end of <code>&lt;body&gt;<\/code>, keep <code>{% all include &quot;_html_body.tpl&quot; %}<\/code>, the site&#39;s <code>_js_include.tpl<\/code>, and one final <code>{% script %}<\/code> in their established order. Wires collect browser code for that final script tag; without it a page can render correctly while its buttons do nothing.<\/p>\n<h2>Reuse markup with includes and categories<\/h2>\n<p>Extract repeated markup into a partial and pass its inputs explicitly.<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% include &quot;_garden_card.tpl&quot; id=id %}\n<\/code><\/pre>\n<p>Inside the partial, read the resource using <code>m.rsc[id]<\/code>. Keep the partial focused on one component so another page can reuse it without inheriting unrelated page behavior.<\/p>\n<p>Use a category include when the representation depends on the resource&#39;s category:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% catinclude &quot;_garden_card.tpl&quot; id %}\n<\/code><\/pre>\n<p>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 <a href=\"\/id\/2941\">Find the template used by a page<\/a>.<\/p>\n<p>For the example above, save the fallback as <code>priv\/templates\/_garden_card.tpl<\/code>. An event-specific version is <code>_garden_card.event.tpl<\/code>. A resource named <code>garden_open_day<\/code> can override both with <code>_garden_card.name.garden_open_day.tpl<\/code>. Test an event and an ordinary text resource: the latter should still use the fallback.<\/p>\n<h2>Display values safely<\/h2>\n<p>Resource properties read through <code>m.rsc<\/code> follow Zotonic&#39;s content handling. Query arguments and values returned by custom models do not automatically have the same guarantees.<\/p>\n<p>Escape plain text from those sources:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">&lt;p&gt;{{ q.term|escape }}&lt;\/p&gt;\n<\/code><\/pre>\n<p>Do not mark arbitrary user input as safe HTML. Decide at the model or content boundary whether a field contains text, sanitized HTML, a URL, or another type. Keep that decision consistent across templates and API responses.<\/p>\n<p>When a value renders unexpectedly, inspect its type and translation behavior before applying more filters. See <a href=\"\/id\/1461\" class=\"doc-reference doc-reference-filter\"><code>filter#escape<\/code><\/a>, <a href=\"\/id\/2960\">Expose data through a model<\/a>, and <a href=\"\/id\/1536\">Keep permission checks at the boundary<\/a>.<\/p>\n<h2>Cache a template fragment<\/h2>\n<p>First measure the work performed by the fragment. Cache a fragment only when you know which inputs and data changes affect its output.<\/p>\n<p>Check <a href=\"\/id\/1357\" class=\"doc-reference doc-reference-tag\"><code>tag#cache<\/code><\/a> for the supported duration, variation, and dependency arguments. A fragment containing a user&#39;s private information must not be shared between users through an incomplete cache key. Language and resource identity can also change the result.<\/p>\n<p>Test a cache hit, then change the underlying content and check invalidation. During debugging, the Development page can disable template cache tags. Restore that setting before measuring normal page behavior. See <a href=\"\/id\/2979\">Distinguish stale cache data from stale code<\/a> and <a href=\"\/id\/2983\">Choose checks for a change<\/a>.<\/p>\n<p>For a public resource card, a starting point is:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% cache 60 garden_card vary=id vary=z_language if_anonymous %}\n    &lt;a href=&quot;{{ id.page_url }}&quot;&gt;{{ id.title }}&lt;\/a&gt;\n{% endcache %}\n<\/code><\/pre>\n<p>The resource ID varies the entry and is a cache dependency; language separates translations. This example caches only anonymous requests. If the fragment also reads connected resources, add the corresponding dependencies. Rename a shared cache block when its output contract changes.<\/p>"}},"is_mailing_opt_out":false,"slug":"create-a-page-layout","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"is_featured":false,"content_group_id":{"id":339,"is_a":["meta","content_group"],"name":"default_content_group","title":{"_type":"trans","tr":{"en":"Default Content Group"}},"uri":"https:\/\/zotonic.com\/id\/default_content_group"},"category_id":{"id":317,"is_a":["meta","category"],"name":"developerguide","title":"Developer guide","uri":"https:\/\/zotonic.com\/id\/developerguide"},"publication_start":"2022-02-15T10:01:00Z","is_website_redirect":false,"github_url":"https:\/\/github.com\/zotonic\/zotonic\/tree\/master\/doc\/developer-guide\/templates.rst","pivot_location_lng":null,"name":"doc_developerguide_templates","is_unfindable":false,"is_published":true,"doc_editorial_edges":{"hasreference":[2325,2942,2943,2946],"subject":[2554,2563,2620,2630,2641,2685]},"summary":{"_type":"trans","tr":{"en":"Use an existing site base template as your starting point. Put shared document structure in the base and page-specific markup in blocks."}},"pivot_geocode":null,"custom_slug":false,"created":"2020-05-30T05:47:19Z","uri":null,"date_is_all_day":false,"is_dependent":false,"is_page_path_multiple":false,"publication_end":"9999-08-17T12:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_editorial_bundle":true,"creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"seo_noindex":false,"modified":"2026-10-07T20:45:37Z","title_slug":{"_type":"trans","tr":{"en":"create-a-page-layout"}}},"uri":"https:\/\/zotonic.com\/id\/1352","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1352"}},"status":"ok"}