#### This Page

# Events

As Lektor executes and builds it emits various events that plugins can respond to. This gives a list of all of those events.

## Handling Events

Events are handled by implementing a method with the name of the event and the prefix `on_` on the plugin and underscores instead of dashes. So for instance if the event is called process-template-context the method to implement is `on_process_template_context`. It's important to additionally always catch extra parameters in a `**extra` parameter so that the plugin does not break if an event starts sending additional parameters in the future.

## Emitting Events

If you want to emit your own events you can do that from the environment's plugin controller:

    self.emit('your-signal', parameter='value')

This emits a signal named `your-plugin-your-signal`. The signal prefix is taken from the plugin ID which is set in `setup.py`.

#### after-build

This event is emitted after an individual source is built.

#### after-build-all

This event is emitted after all sources are built.

#### after-prune

This event is emitted after unused data in the build folder is removed.

#### before-build

This event is emitted before an individual source is built.

#### before-build-all

This event is emitted before all sources are built.

#### before-prune

This event is emitted before unused data in the build folder is removed.

#### markdown-config

This event is emitted while the Markdown renderer is configured.

#### markdown-lexer-config

This event is emitted after the renderer is made, but before it is used.

#### markdown-meta-init

This event is emitted before the markdown meta information is set.

#### markdown-meta-postprocess

This event is emitted after the markdown meta information is set.

#### process-template-context

An event that can be handled to customize the template context.

#### server-spawn

Emitted right after the server was started.

#### server-stop

Emitted right before the server stops.

#### setup-env

Emitted right after the plugin is associated with the environment.

## Comments