Last modified: Dec 03, 2026

How to Work With Python Pelican

Pelican is a static site generator written in Python. It turns plain text files into a fast, secure website. You write content in Markdown or reStructuredText. Pelican then builds the HTML for you.

This guide walks you through the whole workflow. You will install Pelican, create a project, write posts, change themes, and publish your site. The steps are simple and beginner friendly.

Why Choose Pelican

Static sites are quick to load. They have no database and no server-side code. That makes them fast and safe.

Pelican is a great fit for blogs and project pages. It is pure Python, so it feels natural if you already code in Python. Writing a class or a method in your own scripts will feel just as familiar as writing a post in Pelican.

Pelican also supports plugins, themes, and custom settings. You can start small and grow later.

Install Pelican

First, make sure you have Python 3 installed. Then create a virtual environment. This keeps your project clean.


python -m venv pelican-env
source pelican-env/bin/activate
pip install pelican markdown

The markdown package lets you write posts in Markdown. If you prefer reStructuredText, install docutils instead. Both work well with Pelican.

Create Your First Project

Run the quickstart command. Pelican asks a few questions about your site.


pelican-quickstart

You will be asked for a site title, author name, and URL. Accept the defaults for the rest. Pelican creates a folder structure for you.

The key folders are content for your posts and output for the generated site. The pelicanconf.py file holds your settings.

Write Your First Post

Create a new file inside the content folder. Name it something like first-post.md. Add a header block at the top. This metadata tells Pelican the title, date, and category.


Title: My First Post
Date: 2024-01-15 10:00
Category: News
Tags: python, pelican
Slug: my-first-post
Author: Your Name
Summary: A short intro to my first Pelican post.

This is the body of my post.

## A Subheading

Pelican turns this Markdown into HTML.

Save the file and build the site. Pelican reads every file in the content folder and creates the pages.


pelican content

The output appears in the output folder. Open index.html in your browser to see the result.

Preview Your Site Locally

Pelican includes a development server. It rebuilds the site when files change.


pelican --listen

Open http://localhost:8000 in your browser. Edit a post and refresh the page. The change shows up right away.

This fast feedback loop makes writing pleasant. You focus on content and let Pelican handle the rest.

Understand the Settings File

The pelicanconf.py file controls your site. It is a plain Python file. You can set variables, loops, and simple logic.


# Basic site settings
AUTHOR = "Your Name"
SITENAME = "My Pelican Site"
SITEURL = ""

# Paths
PATH = "content"
OUTPUT_PATH = "output"

# Theme
THEME = "themes/my-theme"

# Feeds and pagination
FEED_ALL_ATOM = "feeds/all.atom.xml"
DEFAULT_PAGINATION = 5

Because the file is Python, you can keep settings organized. If your site grows, you can split settings into modules. That pattern is similar to how you would organize code with inheritance in Python explained in other guides.

Add a Theme

Pelican ships with a default theme. You can also install themes from the community.


pip install pelican-themes

Then set the theme name in your config file. For a custom theme, point the THEME variable to a folder. A theme contains templates written in Jinja2.

The main templates are base.html, index.html, and article.html. You can override any of them. Start with a copy of the default theme and change one file at a time.

Organize Content and Pages

Pelican has two content types: articles and pages. Articles appear in feeds and categories. Pages are static, like an About page.


Title: About
Date: 2024-01-10
Slug: about

This is a static page about me.

Save it in the content folder. Pelican detects pages by their metadata. You can also use subfolders to group content. Each subfolder can have its own settings.

Tags and categories help readers find posts. Keep tag names short and consistent. One word per tag works best.

Work With Templates

Templates use Jinja2 syntax. You can loop over articles, show dates, and link tags.


{% for article in articles_page.object_list %}
  
{% endfor %}

This snippet lists posts on the index page. The article.url value points to the generated page. The article.summary value comes from your metadata.

Use Plugins

Plugins add features like sitemaps, related posts, and reading time. Install them and list them in your config.


PLUGINS = ["sitemap", "related_posts"]

Some plugins need extra settings. Read each plugin's docs before enabling it. Keep the plugin list short at first. Add more only when you need them.

Build and Publish

When you are happy with the site, build it for production. Use a separate config file for the live URL.


pelican content -s publishconf.py

The output folder now holds the final site. Upload it to any static host. GitHub Pages, Netlify, and Cloudflare Pages all work well.

You can also automate the build. A small script or CI job can run Pelican on every push. That keeps your live site in sync with your content.

Common Tips and Pitfalls

Keep dates in the correct format. Pelican expects YYYY-MM-DD HH:MM. A wrong format can hide a post from the index.

Check your SITEURL before publishing. Links break when the URL is wrong.

Use relative paths for images inside posts. Store images in the content folder so Pelican copies them to the output.

Finally, keep your content folder tidy. Clear file names and short tags make the site easier to maintain.

Conclusion

Pelican is a simple and powerful static site generator. You install it once, write posts in Markdown, and build a fast site in seconds. The settings file is plain Python, so you stay in familiar territory.

Start with the quickstart, add a few posts, and preview locally. Then pick a theme and publish. With a small amount of practice, the whole workflow becomes quick and repeatable. Pelican gives you full control over your content and your output.