Lektor builds a website by taking all the files in the content/ folder, processing them according to the rules of your Models and rendering them by using templates. Don't worry. It's easier than it sounds.

One Folder — One Page

Each page (or each URL) corresponds to a folder below the content/ folder. There can be as many folders as you want and they can be arbitrarily nested. Within each folder there needs to be at least one file, the content file: Into that file, your data goes.

All the other files in a folder are considered attachments of the page.

Here is an example structure from a website:


One Page — One URL

Out of each file, Lektor builds exactly one final page on exactly one URL. So if you have content/portfolio/project-a/ the rendered end result will be at /portfolio/project-a/.

Page, Model and Template

Each page is associated with a model and a template. Each page needs to have a model that defines which fields exist. The template by default matches the model name but it can be overridden on a per-page basis.

So how is the model selected? Either explicitly in the file with the _model key or by configuration and convention. Lektor will select the default model based on trying things in this order:

  1. configured model in contents file
  2. model configured from a parent model for all children
  3. model matching the page ID
  4. the model named page

The template is always the name of the model with .html as extension. It can be overridden in the content file with the _template field.

Content File Format

So now it's time to talk about the content file. The content file is just a UTF-8 encoded text file with the .lr extension. It can be edited with any text editor that supports UTF-8 as character encoding. This file consists of multiple data fields according to the model. The format is very simple:

_model: page
title: The Page Title

The page body goes here

Fields are separated by three dashes --- and follow the format key: value. For values with multiple lines it's recommended to insert two newlines after the key. The format of each field is specific to how the model is configured.

Some fields are plain text, others can be markdown syntax and more. These fields become available for rendering in the template automatically.

If you want to use --- itself in the document text, just add another dash. This means ---- will render as --- and ----- will render as ---- etc.

Fields prefixed with an underscore are so-called system fields. They are provided by Lektor and customize behavior within Lektor. For a list of available fields see System Fields.