Template Inheritance using Extend and Block
Step 1: Create a folder name template-inheritance for the project.
mkdir template-inheritance
cd template-inheritance
Step 2: Install pug client to use the pug command.
npm install pug-cli -g
Template Inheritance: Extend and Block in Pug
While creating websites or different web applications, we can first create a base HTML template, and build different pages on top of the base template. This concept of using building pages over a base template is called Template Inheritance. It’s a powerful feature available in web template engines like Pug. We can use template inheritance in Pug using “extend” or “block”.
In this article, we will explore how we can use template inheritance in Pug, along with some examples.
Table of Content
- Template Inheritance in Pug
- Extend in Pug
- Block in Pug
- Template Inheritance using Extend and Block
- Advantages of Template Inheritance