Building Pelican

Documenting my journey to understanding the Pelican system.

This is intended to be a resource document for ordinary people interested in the Pelican static blog generator. It is a lot to read. It was a lot to write. My hope is that others may benefit from the effort.

Learning How to Build My Blog Using Pelican.


  1. An Overview of My System
    a - Remote Web Server
    b - The Local Pelican Install

  2. An Overview of How Pelican Works
    a - Python and Jinja
    b - Templates
    c - Plugins

  3. The Photos Plugin
    a - Where I'm Coming From
    b - Explaining What Confused Me

1. An Overview of My System

The "system" I'm describing is made up of at least two physically separate computers: one owned by Digital Ocean (the Remote Web Server), and one owned by me (Brilliant, or the Local Pelican Install).

1a - Remote Web Server

This site ( runs on a DigitalOcean droplet. Nginx is the server engine.

The server only serves content. Creation of the content happens elsewhere; in my case, on a tiny utility computer in my office.

You have to have some way of getting your Pelican-generated content uploaded to your remote web server. There are multiple ways to do that. I use ssh to work with these machines. Setting up ssh access is a large topic all its own, and is not in the scope of this exercise. I'm thinking about working something up on that.

Pelican is not installed on the web server droplet.

1b - The Local Pelican Install

All the editing of docs happens here in my office on a little Lenovo i3 machine I call Brilliant. Brilliant runs Ubuntu.

The actual Pelican package is installed on here on Brilliant. I use the old method of simply installing things like Pelican system-wide rather than using venv or any sort of virtual machine. There are instructions on how to do installs in virtual environments here.

You will want to read over the pelican docs before starting to do the install. You will not come away from reading those with a sense of full comprehension, unless you are a career web developer, in which case you probably don't need to read this blog page.

However, reading through those few short pages will give you a foundation of knowledge upon which you can build the fuller understanding you will want in order to use Pelican.

The documentation for Pelican is found here.

Pelican on Github is found here.

Doing it my way, the command: sudo pip3 install "pelican[markdown]" places the Pelican installation in /usr/local/lib/python3.8/dist-packages/pelican/ on my editing machine, not the web server machine. That was major discovery as I tried to understand how the parts worked together to provide the desired result.

When I finish a post, I run a little bash script I created containing two lines: make html and one rsync line that uploads the new content to /var/www/ on the remote web server. (Details in Process Overview)

2. An Overview of How Pelican Works

2a - Python and Jinja

There are two main components to Pelican. Python and Jinja.

You probably know what Python is (very popular programming language), but you may not know what Jinja is.

Jinja is a templating system that sits between the output of a Python program and the desired web page interface intended for the end-user.

I use a Python/Jinja partnership to run my bespoke home automation system. My Python code sends data to Jinja template files, which are HTML with special Jinja syntax in them. My local-network-only web server then serves up the Python output as filtered by Jinja templates.

The result looks like this:

Image: Browser interface for Shop Pi.

The same thing happens in Pelican.

The Jinja templates give Pelican its theming capabilities. The default theme for Pelican is notmyidea. All of the theme-specific files live in the /usr/local/lib/python3.8/dist-packages/pelican/themes/notmyidea/ folder. A theme can have its own .css file, as well as unique javascript files and will certainly have theme-specific Jinja templates. More on those in coming up in a bit. First let's look at the process overview.

Process Overview

I write my posts in plain-text using Markdown syntax (I use VSCode for this), and the files have an .md extension.

This is what it looks like:

Image: an example of markdown

When I want to see how it looks, the make html command prepares the files, and an rsync command uploads them. Then I can see them using my browser. At this point they are live, so this process would NOT be be optimum for a commercial website. Just sayin'.

SideNote: There are other make ???? commands available, and you can learn more about those in the various docs, or by typing make help on the command line. If you're editing on a Windows system, make may not be your best choice. The invoke method might be best for you. I'm describing here the way I do things, but I do not claim my way is the best way for anyone else, only that my way works for me.

Now back to the overview.

When make html is executed, make runs and reads the content of the Makefile file in that folder. The Makefile is a configuration file telling make how to use Pelican to generate this site. The option (the second word) you use in your make command determines what Pelican does and what sort of output is generated. By using the command make html, I get a complete set of uploadable files to send to the web server. rsync handles the upload, and once that's done, the new data is live on the Internet.

Using the instructions generated by make html, Pelican processes each .md file and creates a .html file for each one. Pelican filters each .md file through the appropriate Jinja template and, in the end, the created .html files are ready to be uploaded to the webserver machine.

I created a shell script for uploading because the command to do it was too long to remember. I named it It contains two lines and it looks like this:

make html
rsync -avP --chown=www-data:www-data -e 'ssh -p #####' ./output/*

Of course, there's an actual port number in place of the #####, and an actual username and domain name where you see user and domain. Once this finishes, the new content is immediately available through a browser.

2b - Templates

As you read various things on the web about Pelican, you'll read a lot about themes, but will rarely see anything about templates. The Jinja-based theme templates are the power behind Pelican themes.

The initial install of Pelican comes with two themes. You can see those, and where they are installed, by running this command:

greg@brilliant:~/drgergsite$ pelican-themes -lv

. . . which on my install returns:


There are two important folders living in the /usr/local/lib/python3.8/dist-packages/pelican/themes/notmyidea/ folder on my local editing machine. They are templates and static.

The templates folder contains, you guessed it, Jinja templates. We'll come back to that later when we look at the Photos Plugin.

The static folder contains css, fonts, images, and js folders. These folders in the static folder are where you will place any stylesheets or javascript files that your site depends on. The required files get added to the upload list, and when we run rsync (, they are uploaded to the web server.

Out of the box, a Pelican blog using the notmyidea theme uses no javascript. I wanted to have popup photo galleries, though, and that almost definitely meant some form of javascript would be required.

If you play around with your themes at all, you will want to know where the static/css and static/js folders are.

And remember, these folders live on your editing machine and the files are sent up to the web server as needed.

2c - Plug-ins

Image: pelican plugins logo

I only use one plugin as of this writing: the Photos Plugin. Once correctly configured, it works great. But figuring out HOW to get it correctly configured was quite a challenge for me.

3. The Photos Plugin

Disclaimers: Writing good code takes skill. Writing good documentation for good code takes a lot of time and a different set of skills. Finding all that in one person is pretty rare.

This is not a criticism of the Photos plugin team, nor is it a criticism of the provided on Github.

3a - Where I'm Coming From

I've never been a professional anything in the computer world. Well, maybe I'm a professional computer user, but my degrees are not in a computer-related field, and I do not work in hardware or software development.

In the 80's I wrote DOS batch files. In the 90's I started writing some HTML. When I found out about .css stylesheets, I dabbled a bit in those. When WordPress started taking off, I jumped onboard and rode that train a while.

I wrote my first Python program in 2015 after finishing a Codecademy course. I will admit to having written three Python/Tkinter applications for Windows that I use in my real job, so if "get paid for it" makes you a professional, then I guess?

I still learn new stuff every day, and getting Pelican to work with the Photos plugin stretched me. That's why I'm writing this. Maybe someone else can benefit from the expression of these thoughts.

3b - Explaining What Confused Me

I read on Github. I had questions after the first sentence. There appeared to be three use-cases in that sentence: add a photo, add a gallery, add a photo to body text, but I could only find examples of two. I moved on.

The installation went smoothly. No issues there.

The Usage section required me to make assumptions. I did not know for certain if the listed configuration options were supposed to be added by me into or not. Maybe they went in I dug around a bit on Github, and eventually ran across the examples folder. In it was an edited copy of that had some good hints inside.
Learned Thing #1.

I provided the correct absolute path to my pictures folder.
I kept the default PHOTO_INLINE_GALLERY_TEMPLATE = "inline_gallery"

The How to use section gave me another stumble. The phrase, "add the metadata field gallery: {photo}folder to an article" did not register with me. "Metadata field"? I guessed it probably meant the first few lines at the top of the article text. Mine were all sentence case (first caps), but the example was all lower case. Would it work? I guessed. It worked.
Learned Thing #2.

". . . which can be used with Lightbox . . . " What the heck is Lightbox? Do I need it? Do I want it? How would I know?

Scanning and scrolling past the Exif, Captions and Blacklists section, I get to How to change the Jinja templates.

Full stop.

OK. Tuples with data, I get that. But where the heck is the template article.html? At this point, I had no clue. Much later I would discover the pelican-themes -lv command (discussed here).

OK. Three examples:

1. associated image before article. No.
2. add gallery as the end of the article. No.
3. display the thumbnail with a link to the article. No.

I want to put my gallery in the body of the article, and then I want the usual 'previous' and 'next' arrows and such. How do I get that? Does that have a name? What is it called? I don't know.

Now here's the How to make the gallery lightbox section. There's that term again: lightbox. Is that what I'm looking for? So now do I need to install Magnific Popup? Is Magnific Popup a "lightbox"? This looks pretty complicated. Let's not.

So how then, do I get a gallery in my article? I put the pictures in a subfolder, put the Metadata Field in the header of my article but nothing shows up.

I go back to the Photos Plugin repository root, and there I find the examples folder. Buried in content/articles I find which yields up a tidbit of useful information: put gallery followed by two colons, followed by {photo} then the gallery path. Just like the 'metadata' in the article header, but with two colons instead of only one.

I put that line in my article (adjusted to the proper parameters, of course). I do not get a gallery. Why? Well let's think about this. In we have a line that talks about PHOTO_INLINE_GALLERY_TEMPLATE = inline_gallery. Where is that template? So, back to the examples folder. Way down in themes/notmyidea_photos/templates/ I find the Holy Grail: inline_gallery.html.

OK. That implies I need to have this template in my templates, but where the heck are they? I still don't know. After about an hour Googling I finally find a reference to the pelican-themes -lv command.
Learned Thing #3.

Now that I know where to look, I navigate to the templates folder on Brilliant. There is no inline_gallery.html. What the heck? I guess I have to create this myself, which I do using the provided code for that file.

Now I get a gallery! I click on a thumbnail, and it opens, but there are no navigation pointers. Progress, but not home.

Now that I know where the templates are, I feel empowered to make some changes. I try adding bootstrap.css to .../static/css and using the code in the example for bootstrap, but it doesn't work. I'm guessing it's because I'm not using a Bootstrap theme, but I'm not sure.

I go back and start reading up on Magnific Popup because apparently I need something like that to get what I'm looking for.

It quickly becomes obvious to me that I need jquery. I don't know tons about jquery, but I know it has to do with javascript, and I know javascript is related to a package called node, so I sudo apt install nodejs followed by sudo apt install npm (which is the Node Package Manager).

Somewhere I saw I would need two packages: @popperjs/core@^2.10.2 and jquery, so I move to the root of my /themes/notmyidea folder, and install them:

sudo npm install @popperjs/core@^2.10.2
sudo npm install jquery

This creates a node_modules folder in themes/notmyidea and inside that folder are what I'm looking for.

Standing in my .../themes/notmyidea folder, I copy jquery to .../notmyidea/static/js:

sudo cp -a node_modules/jquery/dist/jquery.min.js static/js/

Now it's back to digging into the Magnific Popup docs, including random Google results.

It looks to me like all I need in order to use Magnific Popup is the .css file and the .js file. So I go to their Github repo and snag jquery.magnific-popup.js and magnific-popup.css which I drop into my respective .../static/js/ and .../static/css/ folders.

Then I make two edits to .../notmyidea/templates/base.html as specified with minor tweaks (in red). I haven't figured out if it's possible to post the actual code here, so I'm posting these two screenshots. You can get the code out of the Photos plugin on Github.

First, in the header of base.html I copy/pasted this code:

Image: In head of base.html template.

Then in the body of base.html I copy/pasted this code just before the </body> tag. (slight tweak in red)

Image: In the body of base.html template.

Up to this point, all of the work has been on Brilliant, the Local Pelican Install machine. I thought I needed to have the javascript stuff on the web server machine too. Made sense to my brain, anyway. I later found out that Pelican knows what needs to be on the server machine, and it queues it up to be uploaded.

So that's the end of my circuitous wanderings to get a working photo gallery on my Pelican blog. It was this wandering about blindly that taught me everything of value I shared in the top end of this post. Nothing is wasted unless we waste it intentionally.

Maybe there are good hints in all that verbiage that will help someone else out.

hand pointing up.

link to home page