Before we dive into fetching data, let’s learn a little bit about 11ty layouts using Nunjuks.

Previously, we created an _includes folder. Inside of here we should create two new folders. One will be for our components (or macros), simply named components . Next is layouts , which is where we’re going to be focused in this lesson.

11ty exposes the _includes folders so that we have access to our layouts and components inside of our pages and inside of each other (for example using macros inside of other macros).

Let’s go ahead and create the HTML scaffold for our pages. Inside of /src/_includes/layouts/ we’ll create the base.njk file.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="/styles.css" />

  <title>{{ title }}</title>
</head>
<body class="w-screen h-screen bg-slate-400 flex flex-col text-gray-800 align-center justify-center">  
  <div class="flex flex-col w-screen h-screen">
    <main>
      {{ content | safe }}
    </main>
  </div>
</body>
</html>

Our layout from above will be what we can use to wrap all of our pages for the time being. You can create sub-layouts, or altogether new layouts depending on your needs for the page, but we should only need this one for now.

You’ll notice a few key things that we should probably talk about.