To load plugins, you have to specify them in your settings file. There are two
ways to do so. The first method is to specify strings with the path to the
callables:

PLUGINS=['package.myplugin',]

Alternatively, another method is to import them and add them to the list:

frompackageimportmypluginPLUGINS=[myplugin,]

Note

When experimenting with different plugins (especially the ones that
deal with metadata and content) caching may interfere and the
changes may not be visible. In such cases disable caching with
LOAD_CONTENT_CACHE=False or use the --ignore-cache
command-line switch.

If your plugins are not in an importable path, you can specify a list of paths
via the PLUGIN_PATHS setting. As shown in the following example, paths in
the PLUGIN_PATHS list can be absolute or relative to the settings file:

invoked after all the generators are executed and just before pelican exits
useful for custom post processing actions, such as:
- minifying js/css assets.
- notify/ping search engines with an updated sitemap.

generator_init

generator

invoked in the Generator.__init__

readers_init

readers

invoked in the Readers.__init__

article_generator_context

article_generator, metadata

article_generator_preread

article_generator

invoked before a article is read in ArticlesGenerator.generate_context;
use if code needs to do something before every article is parsed

article_generator_init

article_generator

invoked in the ArticlesGenerator.__init__

article_generator_pretaxonomy

article_generator

invoked before categories and tags lists are created
useful when e.g. modifying the list of articles to be generated
so that removed articles are not leaked in categories or tags

article_generator_finalized

article_generator

invoked at the end of ArticlesGenerator.generate_context

article_generator_write_article

article_generator, content

invoked before writing each article, the article is passed as content

article_writer_finalized

article_generator, writer

invoked after all articles and related pages have been written, but before
the article generator is closed.

get_generators

pelican object

invoked in Pelican.get_generator_classes,
can return a Generator, or several
generators in a tuple or in a list.

get_writer

pelican object

invoked in Pelican.get_writer,
can return a custom Writer.

page_generator_context

page_generator, metadata

page_generator_preread

page_generator

invoked before a page is read in PageGenerator.generate_context;
use if code needs to do something before every page is parsed.

page_generator_init

page_generator

invoked in the PagesGenerator.__init__

page_generator_finalized

page_generator

invoked at the end of PagesGenerator.generate_context

static_generator_context

static_generator, metadata

static_generator_preread

static_generator

invoked before a static file is read in StaticGenerator.generate_context;
use if code needs to do something before every static file is added to the
staticfiles list.

static_generator_init

static_generator

invoked in the StaticGenerator.__init__

static_generator_finalized

static_generator

invoked at the end of StaticGenerator.generate_context

content_object_init

content_object

invoked at the end of Content.__init__ (see note below)

content_written

path, context

invoked each time a content file is written.

feed_written

path, context, feed

invoked each time a feed file is written.

The list is currently small, so don’t hesitate to add signals and make a pull
request if you need them!

Note

The signal content_object_init can send a different type of object as
the argument. If you want to register only one type of object then you will
need to specify the sender when you are connecting to the signal.

One thing you might want is to add support for your very own input format.
While it might make sense to add this feature in Pelican core, we
wisely chose to avoid this situation and instead have the different readers
defined via plugins.

The rationale behind this choice is mainly that plugins are really easy to
write and don’t slow down Pelican itself when they’re not active.

No more talking — here is an example:

frompelicanimportsignalsfrompelican.readersimportBaseReader# Create a new reader class, inheriting from the pelican.reader.BaseReaderclassNewReader(BaseReader):enabled=True# Yeah, you probably want that :-)# The list of file extensions you want this reader to match with.# If multiple readers were to use the same extension, the latest will# win (so the one you're defining here, most probably).file_extensions=['yeah']# You need to have a read method, which takes a filename and returns# some content and the associated metadata.defread(self,filename):metadata={'title':'Oh yeah','category':'Foo','date':'2012-12-01'}parsed={}forkey,valueinmetadata.items():parsed[key]=self.process_metadata(key,value)return"Some content",parseddefadd_reader(readers):readers.reader_classes['yeah']=NewReader# This is how pelican works.defregister():signals.readers_init.connect(add_reader)