terminal labs
Python Mercenaries
in
t
p
f

Lektor Tutorial - pt. 1

Installation & Quickstart

written by Joseph Nix on 2017-04-26

Here are instructions for installing Lektor with pip on a Debian based system. Some output has been removed to save space. Other systems will install dependencies that apt handles here in different ways. There are other ways to install Lektor that are more 'hands off' (installing binaries) or 'hands on' (from the source) depending on your desires found here.

dev@host:~$ mkdir projects
dev@host:~$ cd projects/
dev@host:~/projects$ sudo apt install python-dev libssl-dev libffi-dev imagemagick
dev@host:~/projects$ virtualenv venv
dev@host:~/projects$ . venv/bin/activate
(venv) dev@host:~/projects$ pip install lektor

(venv) dev@host:~/projects$ lektor quickstart
Lektor Quickstart
=================

This wizard will generate a new basic project with some sensible defaults for
getting started quickly.  We just need to go through a few questions so that
the project is set up correctly for you.

Step 1:
| A project needs a name.  The name is primarily used for the admin UI and
| some other places to refer to your project to not get confused if multiple
| projects exist.  You can change this at any later point.
> Project Name: tutorial

Step 2:
| Your name.  This is used in a few places in the default template to refer
| to in the default copyright messages.
> Author Name [Dev,,,]:

Step 3:
| This is the path where the project will be located.  You can move a
| project around later if you do not like the path.  If you provide a
| relative path it will be relative to the working directory.
> Project Path [/home/dev/projects/tutorial]: 

Step 4:
| Do you want to generate a basic blog module?  If you enable this the
| models for a very basic blog will be generated.
> Add Basic Blog [Y/n]: y

That's all. Create project? [Y/n] y

Now let's take a look at what the quickstart has produced. Here we see all of the initial folders (in blue) and files. The names of the folders indicate what sort of data they hold in a pretty straight forward way, as do the individual file names. We'll dig into them a little more soon.


dev@host:~/projects$ cd tutorial/
dev@host:~/projects/tutorial$ ls -R
.:
assets  content  models  templates  tutorial.lektorproject

./assets:
static

./assets/static:
style.css

./content:
about  blog  contents.lr  projects

./content/about:
contents.lr

./content/blog:
contents.lr  first-post

./content/blog/first-post:
contents.lr

./content/projects:
contents.lr

./models:
blog.ini  blog-post.ini  page.ini

./templates:
blog.html  blog-post.html  layout.html  macros  page.html

./templates/macros:
blog.html  pagination.html

For now, let's not delay the fun! Let's run the server! Running the server is easy to do, and accomplishes a few things. Notice it tells us where it's grabbing configuration data, from tutorial.lektorproject, where it's compiling it's end product HTML files to, the .cahce dir, and where it's serving these files to, http://127.0.0.1:5000/. After that it builds the HTML that's available at that address.


dev@host:~/projects/tutorial$ lektor server
 * Project path: /home/dev/projects/tutorial/tutorial.lektorproject
 * Output path: /home/dev/.cache/lektor/builds/66bd4ffa5a06350a8b5a248069a1f528
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Started source info update
Finished source info update in 0.23 sec
Started build
U index.html
U about/index.html
U projects/index.html
U blog/index.html
U static/style.css
U blog/first-post/index.html
Finished build in 0.07 sec
Started prune
Finished prune in 0.00 sec

« Previous | Lektor Tutorial - pt. 1 | Next »