-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Eleventy By Example
By :
While the base layout is more maintainable, we can make it easier to reconfigure by breaking the layout down into smaller pieces called includes. These includes will be the beginning of taking the code and turning them into building blocks that can be remixed into different layouts as necessary.
To start, we need to identify the smaller pieces of the base template. Let’s create a header.html file in the src/_templates/includes directory and move all the HTML meta information and visible site header into that file. Everything from the DOCTYPE element to the header element should be removed from base.html and moved into the new file.
While we’re refactoring the header, let’s also move the <nav> element into its own include, as well. 11ty templates can be nested. This means we can include files inside other files. In this case, the header.html include can include navigation.html.
Create a navigation.html file in the includes...