Layouts configuration
⚠️ Deprecation notice
The docs on this page apply only to the legacy Layouts syntax, that used <extends>
/ <block>
tags. If you're using the new, x-tags Components syntax (which we recommended), you don't need it.
This configuration is now deprecated and will be removed in the next major release.
You may use the layouts
key in config.js
to customize the way you use Layouts:
module.exports = {
build: {
layouts: {
// ... options
}
}
}
Let's take a look at the available options:
Encoding
You may specify the encoding used by your Layout files through the encoding
option:
module.exports = {
build: {
layouts: {
encoding: 'windows-1250',
}
}
}
By default, this is set to utf8
.
<meta charset>
tag in your compiled Template.
Blocks
Normally, Template Blocks are defined through the <block>
tag.
However, you may customize this tag name:
module.exports = {
build: {
layouts: {
slotTagName: 'slot', // default: 'block'
fillTagName: 'fill' // default: 'block'
}
}
}
Now you can use <slot>
tags in the Layout, and <fill>
tags in your Template:
<!doctype html>
<html>
<head>
<style>{{{ page.css }}}</style>
</head>
<body>
<slot name="template"></slot>
</body>
---
title: "A template with a <fill> tag"
---
<extends src="src/layouts/main.html">
<fill name="template"></fill>
</extends>
Root
You may define a path to the directory where your Layouts live:
module.exports = {
build: {
layouts: {
root: 'src/layouts',
}
}
}
This allows you to specify a src=""
relative to the path in that root
key:
<extends src="main.html">
<block name="template">
<!-- -->
</block>
</extends>
root
key and only use project root-relative paths (i.e.
src/templates/template.html
)
Tag
You may use a tag name other than extends
:
module.exports = {
build: {
layouts: {
tagName: 'layout',
}
}
}
<layout src="src/layouts/main.html">
<block name="template">
<!-- ... -->
</block>
</layout>