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.
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:
contents.lr
. 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:
content/
contents.lr
portfolio/
contents.lr
project-a/
contents.lr
thumbnail.jpg
project-b/
contents.lr
thumbnail.jpg
about/
contents.lr
Out of each contents.lr
file, Lektor builds exactly one final page on
exactly one URL. So if you have content/portfolio/project-a/contents.lr
the rendered end result will be at /portfolio/project-a/
.
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 contents.lr
file
with the _model
key or by configuration and convention. Lektor will
select the default model based on trying things in this order:
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.
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
---
body:
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.
Alternatives allow you to localize or internationalize a site.
A quick introduction in how attachments are handled in Lektor.
A summary about using the data bag system to store useful data.
Learn about how to use the flow system to build more flexible pages.
An explanation about how paths in Lektor work.
Brief overview of the system fields in Lektor.
Explains how URLs and slugs work in Lektor.
Comments