Skip to content

Plugin Development

Egbert edited this page Jun 30, 2024 · 24 revisions

Welcome to Pelican Plugin Development!

Let's get the non-production environment setup out of the way so that plugin development starts right away. When I say non-production, I meant nothing gets installed, and no Python virtual environment required.

Your Plugin Repository

To better save all your coding efforts (and mishaps), create a Git repository. You could do git init inside your own myplugin directory. Or you could do it like I do, leverage Github 'create repository' and clone it into your development area on your platform.

cd ~
cd work
gh repo clone <your-github-username>/<your-plugin-name>

There. Now all your works can be saved (or perhaps mostly backtracked into a sane state, as I do).

Development Area

Pelican Repository

We are not making much changes, if at all, toward Pelican itself. Just clone the repository.

cd ~
cd work
git clone https://github.com/getpelican/pelican

A pelican repository has been installed into a newly created pelican directory.

Plugins Repository

Separately, Pelican has a single repository for all its plugins; many plugins are essentially a simple link to OTHERS' repository.

Obtain the pelican plugins by executing:

cd ~
cd work
# Go to Github webpage and fork the `getpelican/pelican-plugins` then perform
gh repo clone <your-github-username>/pelican-plugins

A pelican-plugins repository has been cloned into your newly created pelican-plugins directory.

Our Very Own Website

Now for that "website", your static site-generated (SSG) website, we have a choice of where to put this website content:

  • A separate directory (away from pelican and pelican-plugins) (very common)
  • Hijack (reuse) the pelican repository

Ideally, your actual SSG website would be in a directory of its own.

But this in here is rapid prototyping, we will do very little in the way of doing the HTML webmastering nor CSS page-layout work. So, we make the content directory right there inside your own pelican repo (and throw it away upon completion, or worse, move it to your future plugin repo).

Create a website having no font, no image, no template, no support, no extra; a nice simple web site that our brand new plugin can focus on.

cd ~/work/pelican
# `git pelican` already created the pelican/plugins
mkdir content content/articles content/pages output plugins/myplugin

A Nice Configuration File

Lastly before running pelican, seed your pelicanconf.py with:

DEBUG = True
PATH = 'content'   # our newly created location for our articles/pages to reside in/under
OUTPUT_PATH = 'output'
ARTICLES_PATH = ['articles']
AUTHOR = 'John'
SITENAME = 'My 1st Site'
# for 
PORT = 8000
BIND = '127.0.0.1'

A Make To Rule Them All

Copy the Makefile from pelican/docs up to pelican

cd ~/work/pelican
cp docs/Makefile Makefile

The make utility now can tell you what you can do with this Makefile:

$ make help

Our tight, iterative, develop, run, redevelop, redevelop

$ make
$ make serve
Clone this wiki locally