Lektor Web Site

Project status: complete

This is essentially where I document all the work related to this web site (meta). Essentially Lektor is a static site generator, so I can host the content on any host, including S3. Currently I am planning to host this on a simple AWS instance with nginx.

Objectives

Installation

Simply:

$ pip install lektor

Or follow the instructions on the official web site.

Models

Created children.ini:

[model]
name = Children
label = {{ this.title }}

[fields.title]
label = Title
type = string

[fields.body]
label = Body
type = markdown

And project.ini:

[model]
name = Project
label = {{ this.title }}

[fields.title]
label = Title
type = string

[fields.status]
label = Status
type = string

[fields.body]
label = Body
type = markdown

Templates

Content of children.html:

{% extends "layout.html" %}
{% block title %}{{ this.title }}{% endblock %}
{% block body %}
  <h2>{{ this.title }}</h2>
  {{ this.body }}

<ul class="tree-nav">
  {% for child in this.children %}
    <li><a href="{{ child|url }}">{{ child.title }}</a></li>
  {% endfor %}
</ul>
{% endblock %}

And project.html:

{% extends "layout.html" %}
{% block title %}{{ this.title }}{% endblock %}
{% block status %}{{ this.status }}{% endblock %}
{% block body %}
  <h2>{{ this.title }}</h2>
  <h3>Status: {{ this.status }}</h3>
  {{ this.body }}
{% endblock %}

Syntax Highlighting

I use the lektor-markdown-highlighter plugin. To install:

$ lektor plugins add markdown-highlighter

A new configuration file had to be added configs/markdown-highlighter.ini with:

[pygments]
style = tango

The layout.html template had to be updated to add (just after the css statement):

<link rel="stylesheet" href="{{ get_pygments_stylesheet()|url }}">

Atom Feed

Install the plugin:

lektor plugins add lektor-atom

I added a simple configs/atom.ini file with:

[blog]
name = nuntz.com
source_path = /
url_path = /feed.xml
items = site.query('/blog')

Hosting the Content on an Ubuntu AWS EC2 Instance

I use Ubuntu 16.04 LTS on a nano instance, with nginx as the web server. To install nginx:

sudo apt-get install nginx

The document root is /var/www/html, it has to be writable by default ubuntu user, so:

sudo chown -R ubuntu.ubuntu /var/www/html

To configure the deployment, we update the nuntz.com.lektorproject file to add:

[servers.production]
enabled = yes
name = Production
target = rsync://ubuntu@nuntz.com/var/www/html
default = yes

That's it. We can deploy the content with:

lektor deploy