118 lines
2.3 KiB
Plaintext
118 lines
2.3 KiB
Plaintext
|
title: Creating a Theme
|
||
|
---
|
||
|
sort_key: 30
|
||
|
---
|
||
|
summary: Explains themes structure and theme.ini file.
|
||
|
---
|
||
|
body:
|
||
|
|
||
|
!!!! Not implemeted yet
|
||
|
|
||
|
You could create a basic empty theme with the following command:
|
||
|
|
||
|
```bash
|
||
|
$ lektor new theme <theme-name>
|
||
|
```
|
||
|
|
||
|
Example:
|
||
|
|
||
|
```bash
|
||
|
$ lektor new theme demo-theme
|
||
|
```
|
||
|
|
||
|
|
||
|
## Theme components:
|
||
|
|
||
|
A theme could provide templates, assets, and models (also flowdocks):
|
||
|
|
||
|
```
|
||
|
demo-theme
|
||
|
├── assets
|
||
|
├── models
|
||
|
├── templates
|
||
|
└── flowdocks
|
||
|
```
|
||
|
|
||
|
## The theme_settings variable
|
||
|
|
||
|
A `theme_settings` section in `.lektorproject` file could be used for
|
||
|
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>
|
||
|
```
|
||
|
|
||
|
## The theme.ini file
|
||
|
|
||
|
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
|
||
|
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"
|
||
|
lektor_minimum_required_version = 3.1
|
||
|
|
||
|
[author]
|
||
|
name = "lektor"
|
||
|
homepage = "http://getlektor.com/"
|
||
|
|
||
|
[original]
|
||
|
author = ""
|
||
|
homepage = ""
|
||
|
repo = ""
|
||
|
|
||
|
[packages]
|
||
|
lektor-disqus-comments = 0.2
|
||
|
```
|
||
|
|
||
|
The `[original]` section is only required if you are porting an existing theme.
|
||
|
|
||
|
!!!! Not implemeted yet
|
||
|
|
||
|
The `lektor_minimum_required_version` is used by Lektor to check the
|
||
|
compatibility when installing a theme.
|
||
|
|
||
|
## Releasing a theme
|
||
|
|
||
|
!!!! Not implemeted yet
|
||
|
|
||
|
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
|
||
|
submodule.
|
||
|
|
||
|
You should also include an `images/` folder with an screenshot and a thumbnail:
|
||
|
|
||
|
```
|
||
|
demo-theme
|
||
|
└── images
|
||
|
├── thumbnail.png
|
||
|
└── screenshot.png
|
||
|
```
|
||
|
|
||
|
Themes added to this lektor-themes repository, will automatically added to the
|
||
|
lektor website.
|