lektor-website/content/docs/themes/creating/contents.lr

112 lines
2.2 KiB
Plaintext
Raw Normal View History

2017-10-26 00:22:17 +02:00
title: Creating a Theme
---
sort_key: 30
---
summary: Explains themes structure and theme.ini file.
---
body:
2018-01-12 00:11:59 +01:00
!!!! Not implemented yet.
2017-10-26 00:22:17 +02:00
You could create a basic empty theme with the following command:
```bash
$ lektor dev new-theme
2017-10-26 00:22:17 +02:00
```
2018-01-12 00:11:59 +01:00
## Theme Components:
2017-10-26 00:22:17 +02:00
2018-01-12 00:11:59 +01:00
A theme could provide templates, assets, and models (also flowblocks):
2017-10-26 00:22:17 +02:00
```
demo-theme
├── assets
├── models
├── templates
└── flowblocks
2017-10-26 00:22:17 +02:00
```
2018-01-12 00:11:59 +01:00
## The theme_settings Variable
2017-10-26 00:22:17 +02:00
2018-01-12 00:11:59 +01:00
A `theme_settings` section in `.lektorproject` file could be used to
2017-10-26 00:22:17 +02:00
parametrize themes:
```ini
[theme_settings]
name = "Lektor"
github_url = "https://github.com/lektor"
```
And those settings will be accessed in templates through the config env
variable:
```jinja
{{ config.theme_settings.<variable_name> }}
```
Example:
```jinja
<a href="{{ config.theme_settings.github_url }}">Github</a>
```
will output:
```
<a href="https://github.com/lektor/lektor">Github</a>
```
2018-01-12 00:11:59 +01:00
## The theme.ini File
2017-10-26 00:22:17 +02:00
Themes could provide a `theme.ini` file, that is optional, but it's required if
you want to add your theme to the lektor community themes.
Example:
```ini
[theme]
name = Demo theme
license = MIT
licenselink = https://github.com/lektor/lektor-demo-theme/blob/master/LICENSE.md
description = Simple, minimal theme for Lektor
homepage = https://github.com/lektor/lektor-demo-theme
tags = simple, minimal, demo
features = blog
2017-10-26 00:22:17 +02:00
lektor_minimum_required_version = 3.1
[author]
name = lektor
homepage = http://getlektor.com/
2017-10-26 00:22:17 +02:00
[original]
author =
homepage =
repo =
2017-10-26 00:22:17 +02:00
[packages]
lektor-disqus-comments = 0.2
```
The `[original]` section is only required if you are porting an existing theme.
2018-01-12 00:11:59 +01:00
!!!! Not implemented yet
2017-10-26 00:22:17 +02:00
The `lektor_minimum_required_version` is used by Lektor to check the
compatibility when installing a theme.
2018-01-12 00:11:59 +01:00
## Releasing a Theme
2017-10-26 00:22:17 +02:00
2018-01-12 00:11:59 +01:00
!!!! Not implemented yet
2017-10-26 00:22:17 +02:00
2018-01-12 00:11:59 +01:00
You could add a theme to Lektor community theme, open a pull request against
[lektor themes](https://github.com/lektor/lektor-themes) adding it as a git
2017-10-26 00:22:17 +02:00
submodule.
2018-01-12 00:11:59 +01:00
You should also include an `images/` folder with a screenshot and a thumbnail:
2017-10-26 00:22:17 +02:00
```
demo-theme
└── images
├── thumbnail.png
└── screenshot.png
```
2018-01-12 00:11:59 +01:00
Themes added to this lektor-themes repository, will automatically be added to the
2017-10-26 00:22:17 +02:00
lektor website.