{"id":12274,"date":"2014-03-12T13:02:35","date_gmt":"2014-03-12T07:32:35","guid":{"rendered":"https:\/\/2thenew.today\/blog\/?p=12274"},"modified":"2014-03-12T13:02:35","modified_gmt":"2014-03-12T07:32:35","slug":"layouts-in-dust-js","status":"publish","type":"post","link":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/","title":{"rendered":"Layouts in Dust.js"},"content":{"rendered":"<p>For building an application with user friendly and consistent UI, we generally use the concept of <strong>&#8220;master page&#8221;<\/strong> and <strong>&#8220;layouts&#8221;<\/strong>, so that just the content can vary within the pages. This helps user to easily navigate through the website  as well as faster loading of the web pages.<\/p>\n<p>For example, generally we make header and footer static which needs to be included in almost all pages. So why not make a single master page for that instead of writing same html code in all pages and just embed the dynamic part accordingly.<\/p>\n<p>In my previous blog on <a href=\"https:\/\/2thenew.today\/blog\/dust-your-views\/\" title=\"Dust.js\">using dust as a view engine<\/a> in your node.js application, i have given a brief introduction about how we can use dust for templating. Now we will learn how to use <strong>dust<\/strong> for <strong>layout management<\/strong>.<\/p>\n<p>Lets consider a simple example and create a <strong>master.dust<\/strong>, which contain the common code which we want to be there in all the pages.<br \/>\n[js]<br \/>\n&lt;!DOCTYPE html&gt;<br \/>\n&lt;html lang=&quot;en&quot;&gt;<br \/>\n  &lt;head&gt;<br \/>\n    &lt;title&gt;Demo- {+title \/}&lt;\/title&gt;<br \/>\n  &lt;\/head&gt;<br \/>\n  &lt;body&gt;<br \/>\n  &lt;div class=&quot;navbar navbar-fixed-top&quot;&gt;<br \/>\n  .<br \/>\n  .<br \/>\n  .<br \/>\n  &lt;\/div&gt;<br \/>\n    {+body \/}<br \/>\n  &lt;footer&gt;<br \/>\n    &lt;div class=&quot;container&quot;&gt;<br \/>\n      &lt;p&gt;&amp;copy; Copyright 2014. someDemo.com&lt;\/p&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  &lt;\/footer&gt;<br \/>\n  &lt;\/body&gt;<br \/>\n&lt;\/html&gt;<br \/>\n[\/js]<\/p>\n<p>Now this master.dust can be included in any page, providing just the body for the html. Lets move on to create <strong>loginPage.dust<\/strong>,<\/p>\n<p>[js]<br \/>\n{&gt;&quot;layouts\/master&quot; \/}<br \/>\n{&lt;title}Login{\/title}<br \/>\n{&lt;body}<br \/>\n  &lt;form class=&quot;form-login&quot; method=&quot;post&quot; action=&quot;login&quot; name=&quot;loginForm&quot; id=&quot;loginForm&quot;&gt;<br \/>\n   .<br \/>\n   .<br \/>\n   .<br \/>\n  &lt;\/form&gt;<br \/>\n{\/body}<br \/>\n[\/js]<\/p>\n<p>Here we have included master.dust on top which is inside layouts folder and also providing value for &#8220;title&#8221; and &#8220;body&#8221; tags. In this way, we can include same html in several pages, without actually repeating the code.<\/p>\n<p>Hope this will help \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For building an application with user friendly and consistent UI, we generally use the concept of &#8220;master page&#8221; and &#8220;layouts&#8221;, so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":4,"footnotes":""},"categories":[1],"tags":[1347,1129,1348,1349,1124],"class_list":["post-12274","post","type-post","status-publish","format-standard","hentry","category-technology","tag-dust","tag-expressjs","tag-layouts","tag-master-page","tag-node-js"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"For building an application with user friendly and consistent UI, we generally use the concept of &quot;master page&quot; and &quot;layouts&quot;, so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Sakshi Tyagi\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Layouts in Dust.js | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"For building an application with user friendly and consistent UI, we generally use the concept of &quot;master page&quot; and &quot;layouts&quot;, so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Layouts in Dust.js | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"For building an application with user friendly and consistent UI, we generally use the concept of &quot;master page&quot; and &quot;layouts&quot;, so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#article\",\"name\":\"Layouts in Dust.js | TO THE NEW Blog\",\"headline\":\"Layouts in Dust.js\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sakshi\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2014-03-12T13:02:35+05:30\",\"dateModified\":\"2014-03-12T13:02:35+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#webpage\"},\"articleSection\":\"Technology, dust, expressjs, layouts, master page, node.js\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#listItem\",\"name\":\"Layouts in Dust.js\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#listItem\",\"position\":3,\"name\":\"Layouts in Dust.js\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sakshi\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sakshi\\\/\",\"name\":\"Sakshi Tyagi\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a42c6deb088e18815dfcfed629c77b032d17bf973881421880b9c5e4ba713739?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Sakshi Tyagi\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/\",\"name\":\"Layouts in Dust.js | TO THE NEW Blog\",\"description\":\"For building an application with user friendly and consistent UI, we generally use the concept of \\\"master page\\\" and \\\"layouts\\\", so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/layouts-in-dust-js\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sakshi\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sakshi\\\/#author\"},\"datePublished\":\"2014-03-12T13:02:35+05:30\",\"dateModified\":\"2014-03-12T13:02:35+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Layouts in Dust.js | TO THE NEW Blog","description":"For building an application with user friendly and consistent UI, we generally use the concept of \"master page\" and \"layouts\", so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and","canonical_url":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#article","name":"Layouts in Dust.js | TO THE NEW Blog","headline":"Layouts in Dust.js","author":{"@id":"https:\/\/2thenew.today\/blog\/author\/sakshi\/#author"},"publisher":{"@id":"https:\/\/2thenew.today\/blog\/#organization"},"datePublished":"2014-03-12T13:02:35+05:30","dateModified":"2014-03-12T13:02:35+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#webpage"},"isPartOf":{"@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#webpage"},"articleSection":"Technology, dust, expressjs, layouts, master page, node.js"},{"@type":"BreadcrumbList","@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog#listItem","position":1,"name":"Home","item":"https:\/\/2thenew.today\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/2thenew.today\/blog\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#listItem","name":"Layouts in Dust.js"},"previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#listItem","position":3,"name":"Layouts in Dust.js","previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.today\/blog\/category\/technology\/#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/2thenew.today\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/2thenew.today\/blog\/"},{"@type":"Person","@id":"https:\/\/2thenew.today\/blog\/author\/sakshi\/#author","url":"https:\/\/2thenew.today\/blog\/author\/sakshi\/","name":"Sakshi Tyagi","image":{"@type":"ImageObject","@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/a42c6deb088e18815dfcfed629c77b032d17bf973881421880b9c5e4ba713739?s=96&d=mm&r=g","width":96,"height":96,"caption":"Sakshi Tyagi"}},{"@type":"WebPage","@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#webpage","url":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/","name":"Layouts in Dust.js | TO THE NEW Blog","description":"For building an application with user friendly and consistent UI, we generally use the concept of \"master page\" and \"layouts\", so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/2thenew.today\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/#breadcrumblist"},"author":{"@id":"https:\/\/2thenew.today\/blog\/author\/sakshi\/#author"},"creator":{"@id":"https:\/\/2thenew.today\/blog\/author\/sakshi\/#author"},"datePublished":"2014-03-12T13:02:35+05:30","dateModified":"2014-03-12T13:02:35+05:30"},{"@type":"WebSite","@id":"https:\/\/2thenew.today\/blog\/#website","url":"https:\/\/2thenew.today\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/2thenew.today\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Layouts in Dust.js | TO THE NEW Blog","og:description":"For building an application with user friendly and consistent UI, we generally use the concept of &quot;master page&quot; and &quot;layouts&quot;, so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and","og:url":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/","og:image":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Layouts in Dust.js | TO THE NEW Blog","twitter:description":"For building an application with user friendly and consistent UI, we generally use the concept of &quot;master page&quot; and &quot;layouts&quot;, so that just the content can vary within the pages. This helps user to easily navigate through the website as well as faster loading of the web pages. For example, generally we make header and","twitter:image":"https:\/\/2thenew.today\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"12274","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 03:19:19","updated":"2024-02-29 08:54:37","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.today\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.today\/blog\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tLayouts in Dust.js\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/2thenew.today\/blog"},{"label":"Technology","link":"https:\/\/2thenew.today\/blog\/category\/technology\/"},{"label":"Layouts in Dust.js","link":"https:\/\/2thenew.today\/blog\/layouts-in-dust-js\/"}],"_links":{"self":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts\/12274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/comments?post=12274"}],"version-history":[{"count":0,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/posts\/12274\/revisions"}],"wp:attachment":[{"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/media?parent=12274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/categories?post=12274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2thenew.today\/blog\/wp-json\/wp\/v2\/tags?post=12274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}