Layouts are Vue components that wrap around your page. They allow you to have the source code for your template in one place so you don’t have to repeat things like your navigation and footer on every page.

You can use the layout attribute to use a layout component for specific page.

Saber loads *.{vue,js} files from ./layouts in your project root and theme directory as layout components, when the desired layout component does not exist, it will fallback to the default layout component in your layouts directory.

Layout components have a prop named page which implements the Page Interface and allows you to access page data.

The page contents will be available as the default slot in your layout component, for example:

A page pages/

title: Hello World
layout: page

Saber is fantastic!

and with the layout component layouts/page.vue:

    <h2 class="page-title">{{ page.title }}</h2>
    <div class="page-content"><slot name="default" /></div>

export default {
  props: ['page']

This page will be rendered to the following HTML:

  <h2 class="page-title">Hello World</h2>
  <div class="page-content">
    <p>Saber is fantastic!</p>

404 page

You can use the 404 layout to customize 404 page.

In production build, Saber will also generate /404.html which will be automatically used as 404 error page by hosting platforms like GitHub pages and Netlify.